文字

SWFShape::drawLineTo

(PHP 5 <= 5.3.0, PECL ming SVN)

SWFShape::drawLineToDraws a line

说明

void SWFShape::drawLineTo ( float $x , float $y )
Warning

此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。

swfshape::setrightfill() draws a line (using the current line style, set by swfshape::setline() ) from the current pen position to point (x,y) in the shape's coordinate space.

返回值

没有返回值。

参见

  • SWFShape::drawLine() - Draws a line (relative)

用户评论:

[#1] lexmanspam at laposte dot net [2005-07-27 00:04:58]

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 :

<?php
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(0xcc0xcc0xcc );
$movie->setRate(24);

$polygone = new SWFShape();
$polygone->setRightFill($polygone->addFill(0xff00));
$polygone->setLine(200x7f00);
$polygone->movePenTo(10000500); // No split needed for movePenTo
$tmp splitForMing(1000050015000500);
for( 
$i $i count($tmp) ; $i++) {
     
$polygone->drawLineTo($tmp[$i][0], $tmp[$i][1]); // C
}
$tmp splitForMing(15000500150005500);
for( 
$i $i count($tmp) ; $i++) {
     
$polygone->drawLineTo($tmp[$i][0], $tmp[$i][1]); // C
}
$tmp splitForMing(15000550010000500);
for( 
$i $i count($tmp) ; $i++) {
     
$polygone->drawLineTo($tmp[$i][0], $tmp[$i][1]); // C
}
$polygone->drawLineTo(1500015000);
$ajout $movie->add($polygone);
$ajout->setName("test");
$movie->output();
?>

上一篇: 下一篇: