Please guide me to modify Fabricjs to add custom icon for Rotation.
I get some of the answers but it is not working fine.
Please let me know the code to change a particular rotation icon only.
Please guide me to modify Fabricjs to add custom icon for Rotation.
I get some of the answers but it is not working fine.
Please let me know the code to change a particular rotation icon only.
the problem with image not showing until you move is because image load is asynchronous. Inline it with data url:
I know this is a pretty old question, but for anyone looking for an easier solution:
https://github.com/pixolith/fabricjs-customise-controls-extension
This plugin is up to date and works perfect for me. You won't have to override the internal logic of fabric js and it's therefor safer to use.
For fabricjs above 1.6.6 changing function object prototype drawControls, small changes on hasRotation condition, result can be seen this JSFidle
Change fabric object prototype "drawControls" like this.
Here is an example and JSFiddle:
@hlozancic's answer overrides a big important part of the prototype. Monkey patching libraries maintained by a community doesn't sit well with me, since the code in those methods could change (and, in fact
drawControls
has changed since July 2nd), without my knowing. Here is an alternative that I prefer:Apologies for not providing a fiddle, and please be aware of the date of this writing.
This code works in Edge ,Chrome , FireFox, Try this, or You can copy the function from core js library file and then you can replace the ctx.drawImage function