CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 12:19:38 GMT
content-type: text/html
server: cloudflare
last-modified: Thu, 28 Oct 2010 14:02:44 GMT
cf-cache-status: DYNAMIC
vary: Accept-Encoding
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=vdvgl%2FxAXwnFvJBCORAuQp0gv17ltnG9B1U0ilvl7eCINrEyGpa%2Bpt1MpQxVzeDKhrIxUpehKYyD3nJirIpidH3tpVmnV1H%2FzzqJU8Q%3D"}]}
content-encoding: gzip
cf-ray: 98d68bf41f6246bc-BOM
alt-svc: h3=":443"; ma=86400
Processing.js
MouseFunctions
Click on the box and drag it across the screen.
Original Processing.org Example: MouseFunctions
// All Examples Written by Casey Reas and Ben Fry // unless otherwise stated. float bx; float by; int bs = 20; boolean bover = false; boolean locked = false; float bdifx = 0.0; float bdify = 0.0; void setup() { size(200, 200); bx = width/2.0; by = height/2.0; rectMode(CENTER_RADIUS); } void draw() { background(0); // Test if the cursor is over the box if (mouseX > bx-bs && mouseX < bx+bs && mouseY > by-bs && mouseY < by+bs) { bover = true; if(!locked) { stroke(255); fill(153); } } else { stroke(153); fill(153); bover = false; } // Draw the box rect(bx, by, bs, bs); } void mousePressed() { if(bover) { locked = true; fill(255, 255, 255); } else { locked = false; } bdifx = mouseX-bx; bdify = mouseY-by; } void mouseDragged() { if(locked) { bx = mouseX-bdifx; by = mouseY-bdify; } } void mouseReleased() { locked = false; }