| 1 |
package svgparser.parser |
|---|
| 2 |
{ |
|---|
| 3 |
import svgparser.parser.IParser; |
|---|
| 4 |
import svgparser.parser.abstract.AbstractPaint; |
|---|
| 5 |
import svgparser.parser.model.Data; |
|---|
| 6 |
import svgparser.parser.style.Style; |
|---|
| 7 |
import flash.display.Shape; |
|---|
| 8 |
import flash.display.Graphics; |
|---|
| 9 |
import flash.display.GraphicsPathCommand; |
|---|
| 10 |
|
|---|
| 11 |
public class Polyline extends AbstractPaint implements IParser |
|---|
| 12 |
{ |
|---|
| 13 |
public static var LOCALNAME:String = "polyline"; |
|---|
| 14 |
|
|---|
| 15 |
private var _commands:Vector.<int>; |
|---|
| 16 |
private var _vertices:Vector.<Number>; |
|---|
| 17 |
|
|---|
| 18 |
public function Polyline() { } |
|---|
| 19 |
|
|---|
| 20 |
public function parse( data:Data ):void |
|---|
| 21 |
{ |
|---|
| 22 |
var target:Shape = new Shape(); |
|---|
| 23 |
var style:Style = new Style( data.currentXml ); |
|---|
| 24 |
|
|---|
| 25 |
var points:Array = data.currentXml.@points.toString().replace(/\s+$/,"").replace(/\s+/g , ",").split(","); |
|---|
| 26 |
_vertices = Vector.<Number>( points ); |
|---|
| 27 |
|
|---|
| 28 |
var comLength:int = (_vertices.length / 2 ) -1; |
|---|
| 29 |
_commands = Vector.<int>([GraphicsPathCommand.MOVE_TO]); |
|---|
| 30 |
for ( var i:int = 0 ; i < comLength ; i++ ) |
|---|
| 31 |
_commands.push( GraphicsPathCommand.LINE_TO ); |
|---|
| 32 |
|
|---|
| 33 |
paint( target, style, data ); |
|---|
| 34 |
data.currentCanvas.addChild( target ); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
override protected function draw( graphics:Graphics ):void { |
|---|
| 38 |
graphics.drawPath( _commands, _vertices ); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
} |
|---|