18910140161

JavaScript-检查对象是否已绘制-堆栈溢出

顺晟科技

2022-10-18 13:09:47

150

我正在尝试使用Animate CC为孩子们创建一个着色游戏。我使用了以下代码:

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();

有一个将应用颜色的影片剪辑,另一个影片剪辑只是对象的轮廓。我的问题是,是否可以检查对象是否完全着色?或者有没有办法得到形状的颜色?


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航