Skip to content

Conversation

enykwest
Copy link

Open issue 1076 asked for the ability to rotate frames at angles other than 90 degrees.

I implemented the new functionality as a new transform tool RotateNearestNeighbor.js in folder src\js\tools\transform (and touched a few other files).

After some debugging related to undo/redo it seems to be working.

enykwest added 12 commits March 27, 2025 07:28
  TransformUtils.js
- added RotateNearestNeighbor.js (duplicate of Rotate.js)
… used as a reference for adding new features.

- updated RotateNearestNeighbor.js to have named function
  ns.RotateNearestNeighbor (but still uses old rotate function)
- added `new pskl.tools.transform.RotateNearestNeighbor(),` to
  src\js\controller\TransformationsController.js
  - added .icon-tool-rotate-nearest-neighbor to icons.css (copy of rotate)
     - keeps deleting itself...
     - fixed, icons.css is autogenerated from the images img/icons .
       copied rotate images to rotate-nearest-neighbor versions
- added to font-icons.css
  .piskel-icon-rotate-nearest-neighborleft:before {
  content: "\e603";
  }

 .piskel-icon-rotate-nearest-neighborright:before {
  content: "\e604";
  }

- edited RotateNearestNeighbor.js to use RotateNearestNeighbor
- added RotateNearestNeighbor.js to src/piskel-script-list.js
The transform "RotateNearestNeighbor" is a clone of rotate. It still uses
`ns.TransformUtils.rotate(frame, direction);`
to perform the transform.
…; as clone of ns.TransformUtils.rotate(frame, direction);
I pivoted away from "rotation" because debugging was giving me issues.
The rotateNearestNeighbor: function in TransformUtils.js now "mirrors"
pixels across the vertical plane.
While we are limited to the hardcoded value of var angle = ...; you can
set this to any angle and rotate appropriately!
- Updated rotateNearestNeighbor in TransformUtils.js to accept an angle argument
- Added a this.angle parameter and a setAngle function to RotateNearestNeighbor.js
    - use 'alt' to set the angle and it is remebered for future use.
Now it properly interacts with undo and redo
@enykwest
Copy link
Author

Suggested Squashed Commit Message:

Added RotateNearestNeighbor Tool with Full Angle Support

  • Implemented RotateNearestNeighbor tool to rotate sprites at any angle using nearest neighbor interpolation.
  • Added support for setting custom rotation angles via prompt.
  • Updated rotation icons for better user experience.
  • Enhanced undo/redo functionality to support custom angles.
  • Cleaned up code and set default rotation angle to 90 degrees.
  • Created 'CONTRIBUTING.md' for contribution guidelines.

@enykwest
Copy link
Author

enykwest commented May 6, 2025

Hi @juliandescottes,

Sorry to bother you. This is my first PR so I am not entirely sure how to proceed and saw you were an active contributor. I submitted this pull request about 2 months ago and I wanted to check if there's anything I can do to help move it forward. Please let me know if any changes are needed or if there's anything else I can assist with.

Thanks for you in advance for your time!
~ @enykwest

@enykwest enykwest mentioned this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant