0

I'm trying to create a coloring game for kids using animate cc. I used the following code:

var drawingCanvas;
var oldPt;
var oldMidPt;
var color;
var stroke = 50;
var index;
var that = this;
this.colorArray = ["#FF0000", "#009900", "#FFFF00", "#0000FF", "#000000", "#FF00FF"];

function init() {
   index = 0;
   createjs.Touch.enable(stage);
   drawingCanvas = new createjs.Shape();
   stage.addEventListener("stagemousedown", handleMouseDown);
   stage.addEventListener("stagemouseup", handleMouseUp);
   that.obj1.addChild(drawingCanvas);
   //that.obj1.update();
}

function handleMouseDown(event) {
   color = that.colorArray[(index++) % that.colorArray.length];
   oldPt = that.obj1.globalToLocal(stage.mouseX, stage.mouseY);
   oldMidPt = oldPt.clone();
   stage.addEventListener("stagemousemove", handleMouseMove);
}

function handleMouseMove(event) {
   var midPt = that.obj1.globalToLocal(stage.mouseX, stage.mouseY);
   drawingCanvas.graphics.setStrokeStyle(stroke, 'round',  'round').beginStroke(color).moveTo(midPt.x, midPt.y).curveTo(oldPt.x, oldPt.y, oldMidPt.x, 
  oldMidPt.y);
   oldPt.x = midPt.x;
   oldPt.y = midPt.y;
   oldMidPt.x = midPt.x;
   oldMidPt.y = midPt.y;
   //stage.update();
}

function handleMouseUp(event) {
   stage.removeEventListener("stagemousemove", handleMouseMove);
}
init();

There is a movieclip where color will be applied and another movie clip above that which is just outline of the object. My question is, is it possible to check if the object is fully colored? Or is there any way to get the shape's color?

TheGunners
  • 185
  • 1
  • 13
  • Have you seen this? https://stackoverflow.com/questions/28191793/way-to-see-if-whole-canvas-has-been-painted-in-one-color-javascript-processin – kiafiore Sep 22 '21 at 06:58
  • @kiafiore thanks for the reply. I'm new to html5. I looked at it. It looks like they are using pixel manipulation. I'm using animate cc for the project. Is there anyway of using getImageData in animate cc? – TheGunners Sep 22 '21 at 10:23
  • Perhaps this can help you? https://community.adobe.com/t5/animate-discussions/getimagedata-in-animate-cc/td-p/8982574 – kiafiore Sep 23 '21 at 13:48

0 Answers0