gpt4 book ai didi

javascript - 在 fabric.js 中更改对象的选择样式

转载 作者:可可西里 更新时间:2023-11-01 14:51:13 27 4
gpt4 key购买 nike

我在我的项目中使用 fabric 插件。当对象被选中时,我们将获得具有以下设计的选定区域。我可以用一些图片将图像附加到选定区域吗,如下所示:-

我使用 , 设置文本

hw[i] = new fabric.Text($(this).val(), {
left : 100,
top : 100,
fontSize : 20
});

目前,我得到:

enter image description here

我希望得到,

enter image description here

谢谢,

最佳答案

虽然你不能直接用 Fabric JS 做到这一点,但有人为它做了一个扩展:

GitHub 网站:https://github.com/pixolith/fabricjs-customise-controls-extension

现场演示:http://pixolith.github.io/fabricjs-customise-controls-extension/example/index.html )

这将允许您分配更改句柄图像及其操作。

添加扩展后你可以添加这样的东西:获取 Action

fabric.Canvas.prototype.customiseControls({
tl: {
action: 'remove',
},
tr: {
action: 'rotate'
},
br: {
action: 'scaleY',
},
});

然后更改图标:

fabric.Object.prototype.customiseCornerIcons({
settings: {
borderColor: 'black',
cornerSize: 25,
cornerShape: 'circle',
cornerBackgroundColor: 'black',
cornerPadding: 10
},
tl: {
icon: 'icon/trashcan.svg'
},
tr: {
icon: 'icon/rotate.svg'
},
br: {
icon: 'icon/scale.svg'
},
});

关于javascript - 在 fabric.js 中更改对象的选择样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18526465/

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