EaselJS改变颜色onMouseOver [英] EaselJS Change Color onMouseOver
问题描述
我已经在HTML canvas元素中实施所有鼠标和向量相关信息后切换到EaselJS。
我已经习惯了EaselJS,它真的很整洁。我特别喜欢容器和它们如何简单地绘制嵌入的形状。但是,我无法弄清楚您是如何实施 shape 的颜色更改的, a>在鼠标上。
我应该从容器中删除形状,并使用新颜色创建一个新的形状?要复杂的事情,如果一个形状部分遮挡另一个,让我们说一个正方形在一个圆圈内,然后onMouseOver不会注册圆圈的正方形。有任何方法。
干杯
编辑:这里是我使用的向量的一个例子绘制我的圆
var circle = new Shape();
circle.graphics.beginStroke(rgba(255,0,0,0.75))
.setStrokeStyle(lw)
.drawCircle(w / 2,h / 2,r)
.endStroke()
.beginFill(rgba(255,255,0,0.5))
.drawCircle(w / 2,h / 2,r-lw / 2)
.endFill();
circle.shadow = new Shadow(rgba(0,0,0,0.5),10,-10,10)
有一个简单的方法来传递一个新的颜色beginFill?我可以使用变量吗? circle.graphics ...
只执行一次,或每次调用 stage.update()
您要将Shape.graphics.beginFill更改为鼠标悬停时不同的颜色。
以下是示例(警告:斜线代码!)
I switched over to EaselJS after having muleheadedly implemented all mouse and vector related information in the HTML canvas element.
I have gotten used to EaselJS and it is really neat. I especially like the containers and how simple they make drawing embedded shapes. However, I can't figure out how you, for example, implement a color change of a shape on a mouse over. Anything as simple as a rectangle changing color from red to green.
Am I supposed to remove the shape from its container and create a new shape with the new color?
To complicate matters, if one shape partially occludes another, lets say a square inside a circle, then onMouseOver will not register for the circle when over the square. Is there any way around this.
Cheers
EDIT: here is an example of the vector I use to draw my circle
var circle=new Shape();
circle.graphics.beginStroke("rgba(255,0,0,0.75)")
.setStrokeStyle(lw)
.drawCircle(w/2,h/2,r)
.endStroke()
.beginFill("rgba(255,255,0,0.5)")
.drawCircle(w/2,h/2,r-lw/2)
.endFill();
circle.shadow=new Shadow("rgba(0,0,0,0.5)",10,-10,10)
Is there an easy way to pass a new color to beginFill? Can I use variable there? Does the circle.graphics...
get executed only once, or every time there is a call to stage.update()
?
You want to change the Shape.graphics.beginFill to a different color on the mouseover.
Here's an example (warning: sloppy code!)
这篇关于EaselJS改变颜色onMouseOver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!