I’m trying to replicate 9-slice from unity. I have two frames, one with items to slice and second one with which will slice items.
Everything is working like it should, the main problem are gradients. They all work via matrices and I’m not very good with math.
All gradients are kept relative to the objects they are located at. But I want to keep the gradient of the object they have sliced.
I know Figma is doing it by default when you select “Intersect selection” but it in code intersect only returns geometry difference between two objects and all fills and gradient you have to move yourself. ChatGPT helped me to keep the scale of the gradient, but he couldn’t help me with offset, it’s always is off. Here is my code:
It works with horizontals gradient that go from left side of object to right side. But if it’s a little bit rotated or scale is not the same it breaks. Can someone help me?