rmouse_y#

The current vertical coordinate of the mouse after activating scale invariant drawing.

Examples#

 1def setup():
 2  py5.window_resizable(True)
 3  py5.window_ratio(1280, 720)
 4
 5  py5.cursor(py5.CROSS)
 6  py5.stroke_weight(10)
 7
 8
 9def draw():
10  py5.background(255, 0, 0)
11  py5.fill(255)
12  py5.rect(0, 0, py5.rwidth, py5.rheight)
13
14  py5.fill(0)
15  py5.text_align(py5.CENTER, py5.CENTER)
16  x, y = py5.rwidth / 2, py5.rheight / 2
17  py5.text_size(200)
18  py5.text(f'{py5.rmouse_x}, {py5.rmouse_y}', x, y - 100)
19  py5.text_size(100)
20  py5.text(f'top={int(py5.ratio_top)} left={int(py5.ratio_left)}', x, y + 100)
21  py5.text(f'scale={round(py5.ratio_scale, 3)}', x, y + 200)

Description#

The current vertical coordinate of the mouse after activating scale invariant drawing. See window_ratio() for more information about how to activate this and why it is useful.

Note that py5 can only track the mouse position when the pointer is over the current window. The default value of rmouse_y is 0, so 0 will be returned until the mouse moves in front of the Sketch window. (This typically happens when a Sketch is first run.) Once the mouse moves away from the window, rmouse_y will continue to report its most recent position.

Underlying Processing field: rmouseY

Updated on May 02, 2022 12:07:22pm UTC