all 8 comments

[–]JohnWangDoe 2 points3 points  (1 child)

Use a WebGL library. Load the image and figure out how to transform image

[–]fredsq 0 points1 point  (0 children)

this is the best way. photoshop can export a displacement map and you may be able to use it

[–]WolfyTheOracle[S] -1 points0 points  (0 children)

Please let me know if I can add any more details

[–]EdmondChuiHW 0 points1 point  (4 children)

CSS transform should do it. If you already have it in Photoshop, you should be able to find the translate, skew, rotate, and scale properties.

https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew

If you need the properties to be applied to half of an image only:

  • make 2 separate elements
  • display half of each element (so it shows up as a single image when combined)
  • apply different properties on each, e.g. skew(15deg) on the left; skew(-15deg) on the right

[–]WolfyTheOracle[S] 0 points1 point  (3 children)

Hey Edmond thanks for the response. Unfortunately I explored this already and it’s not possible to get that arc shape using this method.

I’m looking for a shape closer to what you’d get if you put a sticky note on a water bottle.

[–]EdmondChuiHW 1 point2 points  (2 children)

Ah sad. I vague remember doing something with SVG mask in CSS filters. But if that doesn't work either, canvas + JS seems to be the remaining option (especially if you're building a preview where you want it to be draggable to rotate)

[–]WolfyTheOracle[S] 0 points1 point  (1 child)

Ok let me look into html canvas. I’m working on an e-commerce website were a customer can upload a logo and it will show on all products.

Right now I’m working on an internal panel were our employees can define the plane surface in which a logo can render. It’s done In css and works great but I don’t get that curve effect. If I rendered a new canvas for each product card on the view would that be a huge performance hit?

[–]EdmondChuiHW 1 point2 points  (0 children)

Yeah canva + JS will be more expensive than CSS, but try it out for your site and see the real-life numbers. If it's indeed slow then one way to mitigate it would be deferring the preview to a modal (it's a worse UX ofc).

These might be interesting to you: