Skip to content

Conversation

@michael-lazar
Copy link
Collaborator

This PR adds a new tool to the sidebar ("reference tool") that can be used to resize/orient the reference watermark image

  • Adds buttons to open/show/hide/reset the current reference image
  • Adds new controls to adjust reference opacity, width, and angle
  • Allows mouse click and drag to fine-tune the position of the reference image on the canvas

I hooked everything up to work with the existing hotkeys and menu options. So for example, if you change opacity with the scroll wheel shortcut, it should reflect appropriately in the UI.

My first idea was to add draggable anchors at the corners of the reference image to allow dragging to resize/rotate the image, as commonly used in image editors. But this was a bit too complicated for me to implement in vanilla JS so I settled on putting the controls in the toolbar instead. The values are standard boxes so you can click in them to type in an exact value, or use the scroll wheel inside the input box to quickly increment/decrement the value.

demo.webm

if (o >= a) o = o - a;
} else if (event.deltaY < 5) {
if (o <= (1.0 - a)) o = o + a;
if (event.deltaX > 0 || event.deltaY > 0) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is one part where I didn't understand the existing code, or why the magic number "5" was chosen for the cutoff in positive/negative scrolling?

At least on my system (macbook air m1 + razer deathaddr v2 mouse):

  • Scrolling down is registered as deltaX = 4.0
  • Scrolling up is registered as deltaX = -4.0
  • Holding down the shift key changes the delta on scrolling from deltaX to deltaY
  • Using the touchpad to pinch-to-zoom gives me either positive or negative values centered around 0.

So scrolling was pretty much broken & glitchy for me without making these changes (I could zoom in but I couldn't zoom out).

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure on the magic number either. maybe a resolution thing? some kind of threshold boundary that is crossed? maybe it was too sensitive? hrm.

@grymmjack
Copy link
Owner

@michael-lazar I completely didn't realize you were doing this! I'll integrate if possible and i can grok your PRs.

@grymmjack grymmjack merged commit 09f79d3 into grymmjack:master Feb 26, 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.

2 participants