gpt4 book ai didi

javascript - ExtJS 6 如何更改 Sprite 的颜色

转载 作者:行者123 更新时间:2023-12-03 02:46:00 25 4
gpt4 key购买 nike

如何使用按钮更改绘图的颜色我尝试使用下面的代码,但它不起作用,是否有更有效的方法可以更改 sencha ext js 中的颜色,例如单击按钮颜色网格时会出现?

使用此示例:https://examples.sencha.com/extjs/6.2.0/examples/kitchensink/#free-paint

查看

 tbar: ['->', {
text: 'Color',
handler: function (button) {
var draw = Ext.getCmp('sprite');
if (strokeStyle == yellow) {
strokeStyle: new Ext.util.Color(255,255,0)
button.setText('Yellow');
} else {
strokeStyle: new Ext.util.Color(0,30,255)
button.setText('Blue');
}
}];

组件

 me.sprite = surface.add({
type: 'path',
path: ['M', me.list[0], me.list[1], 'L', me.list[0] + 1e-1, me.list[1] + 1e-1],
lineWidth: 20,
lineCap: 'round',
lineJoin: 'round',
draggable: 'true',
strokeStyle: new Ext.util.Color(0,0,0)
});
surface.renderFrame();

最佳答案

我不熟悉 Ext.draw.* 组件,但根据文档,要更改 Ext.draw.sprite.Sprite 的颜色您可以使用setAttributes()方法如下:

sprite.setAttributes({
strokeStyle: color
});

要选择颜色,您可以使用 Ext.ux.colorpick.Field .

这里是fiddle来说明。

关于javascript - ExtJS 6 如何更改 Sprite 的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48087506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com