I have a div with a background image, a custom background size (which is auto + %), and a custom background position (which is x% y%).
So I have all this data:
- div width
- div height
- div bg size
- div bg image width
- div bg image height
- div bg image position x
- div bg image position y
For example:
- div width: 200px
- div height: 100px
- div bg size: auto 105%
- div bg image width: 400px
- div bg image height: 280px
- div bg image position x: 20%
- div bg image position y: 12%
I need to convert this to PX values to I can recreate it in a canvas.
When I have all the values, I would do something like:
ctx.drawImage(img, sx, sy, swidth, sheight, 100, 100, 200, 100).
But I need to clip the image using sx, sy, swidth and sheight which are the starting coordinates of the clipping and and width and height of the clipping.
Thanks!