note 55178 added to function.swfshape.drawlineto

From: Date: Wed, 27 Jul 2005 07:04:58 +0000
Subject: note 55178 added to function.swfshape.drawlineto
Groups: php.notes 
Request: Send a blank email to php-notes+get-92532@lists.php.net to get a copy of this message
If you have the error <<drawlineto(): failed assertion>> : Ming can't handel drawLineToTo if the distance from the previous point is over 8276.7 pixels (mesured empiriticaly) in the vertical or horizontal axis Why ? Coordinates in SWF are in twips (20 twips = 1 pixel) and 2^16 = 65536 = 3276.8 * 20 So we can assume that coordinates of drawLineTo in SWf are relatives to the previous point, and take 16 bits (plus the sign). Or it can be ming that brings this limitation These measures have been made with ming_setScale(20.00000000); This issue doesn't seem to occur with movePenTo Here's how you can handle this : <? function splitForMing($x1, $y1, $x2, $y2) { $res = array(); $nbSegments = floor(max(abs($x2 - $x1), abs($y2 - $y1)) / 3276) + 1; for($i = 1; $i < $nbSegments ; $i++) { // ($nbSegments - 1) iterations in the loop : the 1st point is assumed to have been already processed ; the last one is already known $res[] = array($x1 + ($x2 - $x1) * $i / $nbSegments, $y1 + ($y2 - $y1) * $i / $nbSegments); } $res[] = array($x2, $y2); return $res; } ming_setScale(20.00000000); ming_useswfversion(6); // With ming 0.3 $movie = new SWFMovie(); $movie->setDimension(20000,8000); $movie->setBackground(0xcc, 0xcc, 0xcc ); $movie->setRate(24); $polygone = new SWFShape(); $polygone->setRightFill($polygone->addFill(0xff, 0, 0)); $polygone->setLine(20, 0x7f, 0, 0); $polygone->movePenTo(10000, 500); // No split needed for movePenTo $tmp = splitForMing(10000, 500, 15000, 500); for( $i = 0 ; $i < count($tmp) ; $i++) { $polygone->drawLineTo($tmp[$i][0], $tmp[$i][1]); // C } $tmp = splitForMing(15000, 500, 15000, 5500); for( $i = 0 ; $i < count($tmp) ; $i++) { $polygone->drawLineTo($tmp[$i][0], $tmp[$i][1]); // C } $tmp = splitForMing(15000, 5500, 10000, 500); for( $i = 0 ; $i < count($tmp) ; $i++) { $polygone->drawLineTo($tmp[$i][0], $tmp[$i][1]); // C } $polygone->drawLineTo(15000, 15000); $ajout = $movie->add($polygone); $ajout->setName("test"); $movie->output(); ?> ---- Manual Page -- http://www.php.net/manual/en/function.swfshape.drawlineto.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55178 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55178&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55178&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55178&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55178&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55178&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55178&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55178&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92532) next »