M
M
MishaPavlov2017-08-01 20:19:52
JavaScript
MishaPavlov, 2017-08-01 20:19:52

How to make an image transformation in the form of an arc in js?

Good day.
There was such a problem - you need to make the transformation of the image in the form of an arc on js, something like this should come out:
9b3ed92abf9a42ad9831a52ed09bc98f.jpg
Maybe there are some libraries, ready-made solutions, or in which direction to dig?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2017-08-02
@MishaPavlov

In general , I wrote it on the basis of a quadratic bezier curve.
But ideally, you still need to write anti-aliasing. The canvas data-offset attribute specifies how strong the rounding is , data-url is a link to the image .
Well, the most important problem, in order to work with images,
uncomment the line //ctx.drawImage(img,0,0,ctxW,ctxH - offset);and comment out The link that will be in the data-url must be on the same host as the script! That is, if the link to the site is localhost/page.php, then the link to the image is localhost/.../name.jpg Or the link must be on the server with the Access-Control-Allow-Origin "*" parameter, otherwise the protection will work and throw an exception
Here is an example of deformationc85423506db84cb2968f8ec0c99066b9.PNG

T
trushka, 2017-08-01
@trushka

Is that webGL to use. There is a library for working with this business three.js, where you can directly load a 3D model of a glass and sculpt anything on it)) And you can even turn the finished result))
Here, once I played with a teapot like that))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question