We are about to switch to a new forum software. Until then we have removed the registration on this forum.
This is from the excellent book "Algorithms for Visual Design Using Processing". It's a simple code to draw a cube on the screen and then paint it red when clicking on it. There is no error, but the cube doesn't change color. What am I doing wrong?
add_library('peasycam') class MyObject(object): dim = 40 x =0 y=0 z = 0 picked = False c_face = color(255) def pick (self, xp, yp): if (dist(xp,yp,screenX(x,y,z), screenY(x,y,z))<dim): MyObject.picked = True else: MyObject.picked = False def draw3(self): if (MyObject.picked == True): fill(255,0,0) else: fill(MyObject.c_face) box(MyObject.dim) b = MyObject() def setup(): size(200,200,P3D) #PeasyCam(this,100) camera(-100,100,-100,0,0,0,0,0,1) def draw(): b.draw3() def mousePressed(): b.pick(mouseX,mouseY)