Skip to content

Conversation

@FelixAbrahamsson
Copy link

@FelixAbrahamsson FelixAbrahamsson commented Jan 26, 2024

Some credit goes to me and @samedii and a lot of credit goes to @chatgpt

// First, undo scaling
let unscaledX = x / d.scale;
// Then, undo rotation
const rotatedX =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrotated?

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) -
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is actually wrong, chatgpt ... :P

isDefined(maxWidth) ? s.distance(maxWidth) : undefined
0,
0,
maxWidth !== undefined ? s.distance(maxWidth) : undefined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this on purpose or just chatgpt?

canvas,
{ x = 0, y = 0, scale = 1, rotation = { x: 0, y: 0, angle: 0 } } = {}
) => {
if (![0, Math.PI].includes(rotation.angle)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this is the case?

@samedii
Copy link
Contributor

samedii commented Jan 29, 2024

Frontend is not using canvas anymore. We will not be spending more time on this :)

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.

5 participants