Open
Conversation
samedii
approved these changes
Jan 26, 2024
| // First, undo scaling | ||
| let unscaledX = x / d.scale; | ||
| // Then, undo rotation | ||
| const rotatedX = |
| const translatedY = d.y; // y-coordinate remains the same for calculating x | ||
| // Apply rotation | ||
| const rotatedX = | ||
| Math.cos(d.rotation.angle) * (translatedX - d.rotation.x) - |
Contributor
There was a problem hiding this comment.
Math.cos/sin is kinda slow (I'm guessing they don't have a shortcut for PI). But I think it's ok as long as we have much less then 30k objects to render
| // Save the current context state | ||
| _context.save(); | ||
|
|
||
| // Move to where the image will be drawn and apply rotation |
Contributor
There was a problem hiding this comment.
same here _context.translate + _context.rotate is more then enough
| // Move to the center of the rectangle | ||
| _context.translate(s.x(centerX), s.y(centerY)); | ||
|
|
||
| // Rotate the context |
Contributor
There was a problem hiding this comment.
the comment is actually wrong, chatgpt ... :P
| isDefined(maxWidth) ? s.distance(maxWidth) : undefined | ||
| 0, | ||
| 0, | ||
| maxWidth !== undefined ? s.distance(maxWidth) : undefined |
Contributor
There was a problem hiding this comment.
was this on purpose or just chatgpt?
fippli
reviewed
Jan 29, 2024
| canvas, | ||
| { x = 0, y = 0, scale = 1, rotation = { x: 0, y: 0, angle: 0 } } = {} | ||
| ) => { | ||
| if (![0, Math.PI].includes(rotation.angle)) { |
Contributor
|
Frontend is not using canvas anymore. We will not be spending more time on this :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some credit goes to me and @samedii and a lot of credit goes to @chatgpt