GraphiteEditor / Graphite

2D vector & raster editor that melds traditional layers & tools with a modern node-based, non-destructive, procedural workflow.
https://graphite.rs
Apache License 2.0
9.57k stars 465 forks source link

Stretch and tilt ruler increments when canvas is tilted #1482

Open Keavon opened 1 year ago

Keavon commented 1 year ago

If the user tilts the canvas in the viewport, the scale of the increments becomes inaccurate. We want to essentially tilt the measuring system with the canvas. So for example, if the canvas is viewed with a 45° tilt, the increments become √2 = 1.414... wider.

Additionally, the horizontal and vertical ticks (for the vertical and horizontal rulers, respectively) should themselves become tilted to help visualize the fact that they are measuring tilted lines that, if conceptually extended into the document, would remain axis-aligned with document space. It's important that they actually align, so for example the increment ticks at 0 for both rulers would pass through the document origin (if the ticks were extended beyond the rulers). The tick marks would be allowed to tilt up to 45°, at which point the axes would switch and the tilt would become less angled until 90° is reached whereupon the ticks are not tilted but the X and Y rulers mark the dimensions of the Y and X axes, respectively. This behavior of course continues with additional canvas tilt until a full rotation at 360° brings things back to how they started.

Care should be taken to ensure the ticks and numbers generally don't overlap, so the number positioning and tick density would need to intelligently adjust to avoid overlap depending on the canvas zoom level and tilt angle.

This is mostly a web issue, so Svelte/CSS/JS and figuring out some math and logic is required. Plumbing through the canvas tilt, thus extending upon the existing origin point and scale information sent by the backend, would be all the necessary Rust knowledge. This PR can provide a reference for what Rust code needs to change, and feel free to also reach out on Discord to ask for help with this aspect if you're unfamiliar with Rust.

A related followup task is #1969.

HarmanHans commented 2 months ago

Hey, I would like to try and contribute to this! I'm quite new to open source and Rust, so not sure how to best go about things. Thanks!

Keavon commented 2 months ago

Hi @HarmanHans, I'd recommend we discuss this on Discord so you can get a better feel for what's involved and how that fits with your experience, or if there might be other better suited issues to take as a first task. Feel free to ping me in the #general channel.

HarmanHans commented 2 months ago

Ok, sounds good!