I want to make image curve with html5 tool.
I am using Fabric.js for the html5 canvas tool.
Please guide me on how to make curved image on image like mug, glass, cylindrical or circular type of products.
Ref. image is below:
I want to make image curve with html5 tool.
I am using Fabric.js for the html5 canvas tool.
Please guide me on how to make curved image on image like mug, glass, cylindrical or circular type of products.
Ref. image is below:
What you are desiring is called 'perspective warping' and is not available in native 2D canvas.
You can achieve your effect by drawing 1 pixel wide vertical strips of your image with the appropriate Y-offsets.
Here's an outline of how to do it to give you a starting point:
Create an array of y-offsets that form your desired curve:
Create an in-memory canvas:
Use the clipping version of
context.drawImage
to draw 1 pixel wide vertical slices of the image with "curving" y-offsets:Create an image from the temporary canvas and create an image object in FabricJS: