1

I'd like to change rotation and offset of a shape multiple times. I need to "freeze" transformations before applying new rotation and offset, so that when I change offsetX, the shape will move horizontally, not along the X axis of a shape at an angle. Is there a way to do that?

I'm working on a simple editor where the user can crop the image and rotate it. When the user crops the image, the pivot point should be at the center of a crop region (offset). Previous rotations and transforms must be preserved, meaning that even if we change the offset of an image, it'll be rotated at the same angle and will just shift horizontally of vertically relative to the scene (depending on offsetX and offsetY values).

ellis
  • 181
  • 10
  • 1
    Could you provide a visual sketch or cut-down demo of what you need to achieve - I'm guessing the problem is subtle and think I partly understand but I don't want to waste time or effort going off in the wrong direction. – Vanquished Wombat Aug 05 '22 at 07:35
  • https://codesandbox.io/s/editor-sfgxbm?file=/src/Editor.tsx – ellis Aug 05 '22 at 09:02
  • I made a simple demo. The user can crop an image (clip()) and rotate it. I always want the image to rotate around the center of a cropped region. If we apply rotation, then crop, then apply rotation, then crop again, second crop will cut different area. I believe we need to offset an image relative to the screen, not relative to itself (x and y should be parallel to the screen edges, not the image border). – ellis Aug 05 '22 at 09:03
  • 1
    For me the image is draggable and I can zoom with the mouse, but no transformer - how do I get the transformer up to crop & rotate please? – Vanquished Wombat Aug 05 '22 at 09:41
  • I use my own transformers in the project, but for this app I added functions that basically do the same. You can call them in the console: clip(x, y, width, height) and rotate(degrees) – ellis Aug 05 '22 at 10:21
  • Thanks but bear in mind people contributing here are volunteering time out of their day to help you. On that basis you need to do more work to make it easy for us to assimilate the issue you face and provide advice to fix it. – Vanquished Wombat Aug 05 '22 at 12:33

0 Answers0