Skip to content
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

mouse-x, mouse-y, pmouse-x, and pmouse-y reset to 0 when the mouse leaves the canvas #76

Open
ericcervin opened this issue Feb 20, 2022 · 9 comments

Comments

@ericcervin
Copy link

Writing a simple drawing example that connects mouse positions with a line. When my mouse leaves the canvas, the mouse positions all become 0 and a line is drawn to the corner. I checked the java version of Processing and the values are preserved when the mouse is off the canvas.

#lang sketching
(define (setup)
  (size 480 120)
  (smoothing 'smoothed)
  (background 200)

  (stroke 0 102)
  (stroke-weight 4)
  (set-frame-rate! 60)
  )

(define (draw)
  (line mouse-x mouse-y pmouse-x pmouse-y)
  (display (list mouse-x mouse-y pmouse-x pmouse-y))
)
`
@ericcervin
Copy link
Author

mouse1

@soegaard
Copy link
Owner

Thanks for the bug report.
Preserving the previous values (rather than using 0) makes more sense.

I'll see why it happens.

@ericcervin
Copy link
Author

mouse3

@soegaard
Copy link
Owner

There seems to be a difference between Windows and macOS here.

image

I'll look for a tester for Linux.

@soegaard
Copy link
Owner

soegaard commented Mar 3, 2022

Hi Eric,

I have commited what I hope is a fix to this issue.
I have tested it on Windows 10 on DrRacket 8.4.

Let me know if the fix works as expected - or if it needs further adjustments.

/Jens Axel

@ericcervin
Copy link
Author

ericcervin commented Mar 7, 2022

Hello,

Sorry for the delayed reply. This fix works as expected on Windows 7 / DrRacket 8.2

@ericcervin
Copy link
Author

I feel like a related issue still exists.

Was trying to recreate this simple processing sketch

image

I believe the reason this breaks is from mouse-x having an initial value of 0.

image

The example works for me when I constrain the value of mouse-x.

`#lang sketching
(define (setup)
(size 120 120)
(smoothing 'smoothed)
(set-frame-rate! 60)
(background 200)
)

(define (draw)

(translate mouse-x mouse-y)
(scale (/ (constrain mouse-x 1 120) 60.0))
(rect -15 -15 30 30)
)`

@ericcervin ericcervin reopened this Oct 28, 2022
@soegaard
Copy link
Owner

Hi @ericcervin

Thanks for the report.
I see the same as you on Windows.
I don't think the (0,0) is to blame - at least not directly.
Reading the source of Processing, I believe they too use (0,0) as a default.
I also looked at the implemented of scale, but it looks fine.
For now your solution with constrain looks as the best temporary fix.
I'll think about some more about the issue.

@ericcervin
Copy link
Author

Cool. This was my one little bug report from the Racketcon Hackathon

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

No branches or pull requests

2 participants