AE make_mask or shape
/**
* Path creation. As always the basis is taken from
* http://www.redefinery.com/ae/fundamentals/
*
* http://www.redefinery.com/ae/fundamentals/masks/
* with some additions to fit my needs
* Still... Thanks 2 Jeff Almasol aka redefinery
*
*
*
* this builds a path using ternary operators
* I like it that why a lot. Pretty slick
* http://stackoverflow.com/questions/1771786/question-mark-in-javascript
*
* @param {Array of Arrays} path holds the coordinates for the path
* @param {AVLayer} layer The layer to draw on
* @param {String} rowname This is to sort ot rows
* @param {String} pathname The name of the path
* @param {Array of 3 Values 0 -1 } maskcolor The color of the masks always per Glyph
* @param {ADBE Vectors Group} shapegroup The group that contains the path
* @return {ADBE Vectors Group} for reuse.
*
* @todo Get the hang of the diffrent paths in a Character
*/
function make_path(path,layer,charname, rowname, pathname , maskcolor, shapegroup, use_shapes){
var masksGroup = null;
masksGroup = use_shapes ? layer("ADBE Root Vectors Group") : layer("ADBE Mask Parade");
// Get
// PropertyGroup for the shape
// or
// the PropertyGroup for the masks
// masksGroup = layer("ADBE Mask Parade");
if (masksGroup !== null){
var mask = null;
// Create a new mask
if(shapegroup === null && use_shapes === true){
var pregroup = masksGroup.addProperty("ADBE Vector Group");
pregroup.name = charname + ' ' + rowname;
shapegroup = pregroup.addProperty("ADBE Vectors Group");
mask = shapegroup;
}
mask = use_shapes ? shapegroup.addProperty("ADBE Vector Shape - Group") : masksGroup.addProperty("ADBE Mask Atom");
// mask = masksGroup.addProperty("ADBE Mask Atom");
if (mask !== null){
mask.name = use_shapes ? pathname : charname + ' ' + rowname + ' ' + pathname;
mask.color = maskcolor;
var s = new Shape();// new shape object
if (s !== null){
s.vertices = path;
// The close attribute defaults to true
s.closed = false;
// put the path verticies into the shape or mask
maskShape = use_shapes ? maskShape = mask.property("ADBE Vector Shape") : mask.property("ADBE Mask Shape");
// Change the mask shape (not keyframed)
maskShape.setValue(s);
}
}
}
return shapegroup;
}