My first attempt with JSFL. I needed to convert vector drawings to graphics commands to use them with VectorVision (PaperVision3D’s VectorShape classes).
Select the shape on the stage, and run the script. The AS instructions will flow in the output panel.
// with a shape selected
var elt = fl.getDocumentDOM().selection[0];
var contourArray = elt.contours;
var contourCount = contourArray.length;
// get colors
var colors = [];
for (i=1; i
colors.push( contourArray[i].fill.color );
}
fl.trace( 'var g:Graphics3D = new Graphics3D();' );
// enter edit mode to get vertices
elt.beginEdit();
var contourArray = elt.contours;
var contourCount = contourArray.length;
for (i=1; i
var contour = contourArray[i];
fl.trace( '// shape #' + i + ' of ' + (contourCount-1) );
fl.trace( 'g.beginFill( 0x' + colors.shift().substr(1) + ' );' );
var he = contour.getHalfEdge();
var iStart = he.id;
var id = 0;
while (id != iStart)
{
// Get the next vertex.
var vrt = he.getVertex();
if ( id ) fl.trace( 'g.lineTo( '+ vrt.x + ', ' + -vrt.y + ' );' );
else fl.trace( 'g.moveTo( '+ vrt.x + ', ' + -vrt.y + ' );' );
he = he.getNext();
id = he.id;
}
fl.trace( 'g.endFill();' );
fl.trace( '' );
}
elt.endEdit();