So, say you had just a circle on screen and you you wanted it to print “touching” when you touch it. What are good methods to do this?
Here’s something I wrote a long time ago.
function setup()
parameter.integer("a",1,400,200) -- size of a axis
parameter.integer("b",1,400,100) -- size of b axis
xc=250 -- center of ellipse x axis
yc=400 -- center of ellipse y axis
end
function draw()
background(40, 40, 50)
fill(255)
ellipse(xc,yc,a*2,b*2) -- draw ellipse
x=CurrentTouch.x -- touched x value
y=CurrentTouch.y -- touched y value
fill(255,0,0)
ellipse(x,y,5) -- draw point
-- check if point is inside of ellipse or circle
if (x-xc)^2/a^2+(y-yc)^2/b^2 <= 1 then
text("point in ellipse",xc,yc)
end
end
Thanks!