par
scapine » 21 mai 2013, 20:15
Ok, merci. Mais du coup quand j'ajoute un élément avec tab[], j'obtiens bien au final cette structure: tab= array(...), array(....),array(...)? Ou bien il faut que j'utilise une fonction comme join() pour l'obtenir?
Car en supposant que j'ai la bonne structure lors que je fais ceci:
$tab=array();
for($i=0; $i<$n/2; $i++){
for($j=0; $j<2; $j++){
$tab[]=array('x'=> $tab_php[2*$i],'y'=>$tab_php[2*$i+$j]);
}
}
$tab_final=array($tab);
//$tab_final=Array(array('x'=> ,'y'=> ),array('x'=> ,'y'=> )...); forme que doit prendre $tab_final
//image_fond
$masq = new Imagick();
$masq->newImage(500,500, new ImagickPixel('Black')); //$largeur,$hauteur
$masq->setImageFormat('tif');
//polygone
$draw = new ImagickDraw();
$draw->polygon($tab_final);
$draw->setFillColor( 'White' );
//incorporation du polygone dans la masque
$masq->drawImage( $draw );
echo $masq->getImageBlob( );
mais fonction polygon ne marche pas. On m'affiche ce message d'erreur: Fatal error: Uncaught exception 'ImagickDrawException' with message 'Unable to read coordinate array' in /home/marie/www/site_projet/masque_manuel.php:35 Stack trace: #0 /home/marie/www/site_projet/masque_manuel.php(35): ImagickDraw->polygon(Array) #1 {main} thrown in /home/marie/www/site_projet/masque_manuel.php on line 35
Cela veut dire que $tab_final n'est pas de la bonne forme si je me trompe pas.
Ok, merci. Mais du coup quand j'ajoute un élément avec tab[], j'obtiens bien au final cette structure: tab= array(...), array(....),array(...)? Ou bien il faut que j'utilise une fonction comme join() pour l'obtenir?
Car en supposant que j'ai la bonne structure lors que je fais ceci:
[php]
$tab=array();
for($i=0; $i<$n/2; $i++){
for($j=0; $j<2; $j++){
$tab[]=array('x'=> $tab_php[2*$i],'y'=>$tab_php[2*$i+$j]);
}
}
$tab_final=array($tab);
//$tab_final=Array(array('x'=> ,'y'=> ),array('x'=> ,'y'=> )...); forme que doit prendre $tab_final
//image_fond
$masq = new Imagick();
$masq->newImage(500,500, new ImagickPixel('Black')); //$largeur,$hauteur
$masq->setImageFormat('tif');
//polygone
$draw = new ImagickDraw();
$draw->polygon($tab_final);
$draw->setFillColor( 'White' );
//incorporation du polygone dans la masque
$masq->drawImage( $draw );
echo $masq->getImageBlob( );
[/php]
mais fonction polygon ne marche pas. On m'affiche ce message d'erreur: Fatal error: Uncaught exception 'ImagickDrawException' with message 'Unable to read coordinate array' in /home/marie/www/site_projet/masque_manuel.php:35 Stack trace: #0 /home/marie/www/site_projet/masque_manuel.php(35): ImagickDraw->polygon(Array) #1 {main} thrown in /home/marie/www/site_projet/masque_manuel.php on line 35
Cela veut dire que $tab_final n'est pas de la bonne forme si je me trompe pas.