2013-08-30 34 views
3

我在我的项目中使用了fabric插件。当选择对象时,我们使用以下设计获取选定区域。我可以附加图片与一些PIC选择的区域,如下图所示: -在fabric.js中更改对象的选择样式

我使用设置文本,

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

目前,我得到:

enter image description here

,我想得到,

enter image description here

个谢谢,

+0

你只能自定义的角落颜色,角大小,透明边框和东西这样的选择,我不知道这是可能的.. –

+0

@PrasannaAarthi我想texttext:'rgba(0,0,0,0.3)5px 5px 5px',但如果我只想改变模糊sixe即上一个值? – anam

+0

尝试rgba(0,0,0.3)0 0 5px .. –

回答

-1

虽然你不能用面料JS直接做到这一点,有人做了它的扩展:

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

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

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

添加扩展后,您可以添加这样的事情:让行动

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' 
    }, 
});