-
Notifications
You must be signed in to change notification settings - Fork 14
Add rotation to PixelWindow.drawImage #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
canvas.withGraphics(_.drawImage(img.underlying, x, y, width, height, null)) | ||
val at = new java.awt.geom.AffineTransform() | ||
at.translate(x, y) | ||
at.rotate(angle, width/2, height/2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we avoid calling rotate if angle is zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the angle relative or absolute?
Thanks for this enhancement! |
If I could check if |
Yes it would be good if we could avoid allocation of affine transformation if it is not needed. |
Done |
I don't see why we would need an affinetransform if rotation = 0 other than the code would look cleaner if you do not have an if statement. I'm not able to figure out how changing drawImage to using affinetransform internally would break any old code. Don't think it lowers performance by a lot either considering that the normal drawImage also has to scale the Images. I did some tests and It resultet in this: (Have not been able to find the source code for g2d.drawImage, guess this is the second best. Regarding radians or degrees I think that we should use Radians since all math. returns radians / takes in radians :) |
Thanks to @JoPoLu for the code.