Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Ming functions for Flash : SWFShape->drawLineTo()

SWFShape->drawLineTo()

Draws a line ()


Related Examples ( Source code ) » swfshape.drawlineto




Code Examples / Notes » swfshape.drawlineto

lexmanspam

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();
?>


Change Language


Follow Navioo On Twitter
SWFAction
SWFAction->__construct()
SWFBitmap
SWFBitmap->__construct()
SWFBitmap->getHeight()
SWFBitmap->getWidth()
SWFButton
SWFButton->__construct()
SWFButton->addAction()
SWFButton->addASound()
SWFButton->addShape()
SWFButton->setAction()
SWFButton->setDown()
SWFButton->setHit()
SWFButton->setMenu()
SWFButton->setOver()
SWFButton->setUp()
SWFDisplayItem
SWFDisplayItem->addAction()
SWFDisplayItem->addColor()
SWFDisplayItem->endMask()
SWFDisplayItem->getRot()
SWFDisplayItem->getX()
SWFDisplayItem->getXScale()
SWFDisplayItem->getXSkew()
SWFDisplayItem->getY()
SWFDisplayItem->getYScale()
SWFDisplayItem->getYSkew()
SWFDisplayItem->move()
SWFDisplayItem->moveTo()
SWFDisplayItem->multColor()
SWFDisplayItem->remove()
SWFDisplayItem->rotate()
SWFDisplayItem->rotateTo()
SWFDisplayItem->scale()
SWFDisplayItem->scaleTo()
SWFDisplayItem->setDepth()
SWFDisplayItem->setMaskLevel()
SWFDisplayItem->setMatrix()
SWFDisplayItem->setName()
SWFDisplayItem->setRatio()
SWFDisplayItem->skewX()
SWFDisplayItem->skewXTo()
SWFDisplayItem->skewY()
SWFDisplayItem->skewYTo()
SWFFill
SWFFill->moveTo()
SWFFill->rotateTo()
SWFFill->scaleTo()
SWFFill->skewXTo()
SWFFill->skewYTo()
SWFFont
SWFFont->__construct()
SWFFont->getAscent()
SWFFont->getDescent()
SWFFont->getLeading()
SWFFont->getShape()
SWFFont->getUTF8Width()
SWFFont->getWidth()
SWFFontChar
SWFFontChar->addChars()
SWFFontChar->addUTF8Chars()
SWFGradient
SWFGradient->__construct()
SWFGradient->addEntry()
SWFMorph
SWFMorph->__construct()
SWFMorph->getShape1()
SWFMorph->getShape2()
SWFMovie
SWFMovie->__construct()
SWFMovie->add()
SWFMovie->addExport()
SWFMovie->addFont()
SWFMovie->importChar()
SWFMovie->importFont()
SWFMovie->labelFrame()
SWFMovie->nextFrame()
SWFMovie->output()
SWFMovie->remove()
SWFMovie->save()
SWFMovie->saveToFile()
SWFMovie->setbackground()
SWFMovie->setDimension()
SWFMovie->setFrames()
SWFMovie->setRate()
SWFMovie->startSound()
SWFMovie->stopSound()
SWFMovie->streamMP3()
SWFMovie->writeExports()
SWFPrebuiltClip
SWFPrebuiltClip->__construct()
SWFShape
SWFShape->__construct()
SWFShape->addFill()
SWFShape->drawArc()
SWFShape->drawCircle()
SWFShape->drawCubic()
SWFShape->drawCubicTo()
SWFShape->drawCurve()
SWFShape->drawCurveTo()
SWFShape->drawGlyph()
SWFShape->drawLine()
SWFShape->drawLineTo()
SWFShape->movePen()
SWFShape->movePenTo()
SWFShape->setLeftFill()
SWFShape->setLine()
SWFShape->setRightFill()
SWFSound
SWFSound
SWFSoundInstance
SWFSoundInstance->loopCount()
SWFSoundInstance->loopInPoint()
SWFSoundInstance->loopOutPoint()
SWFSoundInstance->noMultiple()
SWFSprite
SWFSprite->__construct()
SWFSprite->add()
SWFSprite->labelFrame()
SWFSprite->nextFrame()
SWFSprite->remove()
SWFSprite->setFrames()
SWFSprite->startSound()
SWFSprite->stopSound()
SWFText
SWFText->__construct()
SWFText->addString()
SWFText->addUTF8String()
SWFText->getAscent()
SWFText->getDescent()
SWFText->getLeading()
SWFText->getUTF8Width()
SWFText->getWidth()
SWFText->moveTo()
SWFText->setColor()
SWFText->setFont()
SWFText->setHeight()
SWFText->setSpacing()
SWFTextField
SWFTextField->__construct()
SWFTextField->addChars()
SWFTextField->addString()
SWFTextField->align()
SWFTextField->setBounds()
SWFTextField->setColor()
SWFTextField->setFont()
SWFTextField->setHeight()
SWFTextField->setIndentation()
SWFTextField->setLeftMargin()
SWFTextField->setLineSpacing()
SWFTextField->setMargins()
SWFTextField->setName()
SWFTextField->setPadding()
SWFTextField->setRightMargin()
SWFVideoStream
SWFVideoStream->__construct()
SWFVideoStream->getNumFrames()
SWFVideoStream->setDimension()
ming_keypress
ming_setcubicthreshold
ming_setscale
ming_setswfcompression
ming_useconstants
ming_useswfversion
eXTReMe Tracker