P5 | Feng Yifei | Observable
Author
Feng Yifei
@fengyfei
Let's build a better world, together.
Comments (1)
AbserAri
Mar 16, 2021
WebGL mouseX and Y should call translate(-width/2,-height/2,0) to locate coordinate. function setup() { createCanvas(100, 100,this.WEBGL); } function draw() { translate(-width/2,-height/2,0); if (mouseIsPressed) { fill(0); } else { fill(255); } ellipse(mouseX, mouseY, 80,80); } ==== function setup() { createCanvas(100, 100); } function draw() { if (mouseIsPressed) { fill(0); } else { fill(255); } ellipse(mouseX, mouseY, 80,80); }
Reply
Add comment
Subscribe to notifications
© 2026 Observable, Inc.
Terms of service
Privacy policy
Product
About
Pricing
Documentation
Release notes
Contact us
Open source
Notebook Kit
Plot
D3
Community
Explore
Forum
Bluesky
YouTube
X
0
Follow
Follow
P5 | Feng Yifei | Observable