Zend PDF: calculating coordinates after rotation -
without getting many details - i'm getting parameters (x1,x2,y1,y2,a,b,α) web tool , need generate pdf document, using zend_pdf library contains green image rotated , positioned on exact coordinates.
now, confuses me zend not allow elements rotated, instead rotates paper. so, assume rotation needs done this
$page->rotate($x1 + ($x2 - $x1) / 2, $y1 + ($y2 - $y1) / 2, - deg2rad($rotation));
because want center of image rotation point, , rotate in reverse orientation resulting image proper rotation.
the tricky part i'm having trouble drawing it. simple call
$page->drawimage($image, $x1, $y1, $x2, $y2);
i'm getting result displayed on diagram - resulting image needs translated well, since (x1,y1) , (x2,y2) not exact coordinates anymore, i'm not sure how calculate them? ideas?
the op confirmed in comment used same values (x1,y1) , (x2,y2) in rotate
, drawimage
calls. pretty obvious sketches, though, coordinates latter call must differ.
fortunately know way green rectangle inscribed in rectangle (x1,y1) (x2,y2) has same center point rectangle. furthermore, have dimensions a , b of green rectangle.
thus, drawimage
parameters must changed to:
$page->drawimage($image, $x1 + ($x2 - $x1) / 2 - $a / 2 , $y1 + ($y2 - $y1) / 2 - $b / 2 , $x1 + ($x2 - $x1) / 2 + $a / 2 , $y1 + ($y2 - $y1) / 2 + $b / 2);
Comments
Post a Comment