0

dragend色の異なる2つの円があり、ユーザーがイベントを使用してオブジェクトを離した後、ドラッグした円の塗りつぶしの色を取得したいと思います。

shapes = new Kinetic.Layer();

circle1 = new Kinetic.Circle({
   x: stage.getWidth() / 3.2,
   y: stage.getHeight() / 3.2,
   radius: radius,
   fill: "blue",
   stroke: "black",
   strokeWidth: 4,
   name: "circle",
   draggable: true
});  

circle2 = new Kinetic.Circle({
   x: stage.getWidth() / 1.5,
   y: stage.getHeight() / 1.4,
   radius: radius,
   fill: "yellow",
   stroke: "black",
   strokeWidth: 4,
   name: "circle",
   draggable: true
 });  

 shapes.add(circle1);
 shapes.add(circle2);
 stage.add(shapes);
4

1 に答える 1

1

図形にハンドラーを追加して使用できますgetFill()

function iGetFill(){
    var color = this.getFill();
}

circle1.on('dragend',function(){
    iGetFill.apply(this);
});

circle2.on('dragend',function(){
    iGetFill.apply(this);
});
于 2012-05-23T00:36:20.217 に答える