Copy link to clipboard
Copied
Hi,
My beloved code in AS2 was based on areas to fill that were buttons with AS:
on(release){iColor.setRGB(_root.fillColor);
delete iColor;
}
And in a palette where each color is also a button with AS:
on(realease){
fillColor = (the HexCode for that color);
}
You just need a container object on the stage that you can attach a new Shape object to. The shape is defined programmatically using the EaselJS graphics API.
For example, where the stage has a movieclip named "myContainer":
// intialize shape
var myShape = new createjs.Shape(); // create a shape to draw in
this.myContainer.addChild(myShape); // attach the shape to a stage object
// define shape
var myPoints = [[0,0], [40, 100], [-20, 80]];
var myStrokeColor = "#0000FF";
var myFillColor = "orange";
var m
...Copy link to clipboard
Copied
RGB filters are very slow in HTML because the canvas element doesn't natively support them, so they have to be emulated in JavaScript. You'd be best off using the drawing API to redraw each colored region from scratch in the requested color.
Canvas mode uses CreateJS, which comprises a set of multimedia APIs. All drawing functions are in EaselJS.
Copy link to clipboard
Copied
Thanks for your answer
Could you refer me some link where I can see something like that in the context of animate cc?
Copy link to clipboard
Copied
You just need a container object on the stage that you can attach a new Shape object to. The shape is defined programmatically using the EaselJS graphics API.
For example, where the stage has a movieclip named "myContainer":
// intialize shape
var myShape = new createjs.Shape(); // create a shape to draw in
this.myContainer.addChild(myShape); // attach the shape to a stage object
// define shape
var myPoints = [[0,0], [40, 100], [-20, 80]];
var myStrokeColor = "#0000FF";
var myFillColor = "orange";
var myStrokeWidth = 2;
// draw shape
var i;
var msg = myShape.graphics; // shortcut to the shape's graphics methods
msg.clear();
msg.setStrokeStyle(myStrokeWidth);
msg.beginStroke(myStrokeColor);
msg.beginFill(myFillColor);
for (i = 0; i < myPoints.length; i++) {
msg.lineTo(myPoints[0], myPoints[1]);
}
msg.closePath();
msg.endStroke();
msg.endFill();
That drawing code at the end can be compacted somewhat by chaining multiple graphics API calls together, like so:
// draw shape
var i;
var msg = myShape.graphics; // shortcut to the shape's graphics methods
msg.clear().setStrokeStyle(myStrokeWidth).beginStroke(myStrokeColor).beginFill(myFillColor);
for (i = 0; i < myPoints.length; i++) {
msg.lineTo(myPoints[0], myPoints[1]);
}
msg.closePath().endStroke().endFill();