def display(self): p.ellipseMode(p.CENTER) p.strokeWeight(4) p.stroke(0) if self.dragging: p.fill(50) elif self.rollover: p.fill(100) else: p.fill(175,200) p.ellipse(self.location.x, self.location.y, self.mass*2, self.mass*2)
def draw(): p.background(255) mouse = np.array([p.mouse.x, p.mouse.y]) center = np.array([width/2, height/2]) mouse = mouse - center p.translate(width/2, height/2) p.strokeWeight(2) p.stroke(0) p.line(0, 0, mouse[0], mouse[1])
def draw(): global x,y,xspeed,yspeed p.background(255) x += xspeed y += yspeed if x > width or x < 0: xspeed *= -1 if y > height or y < 0: yspeed *= -1 p.stroke(0) p.strokeWeight(2) p.fill(127) p.ellipse(x, y, 48, 48)
def draw(): p.background(255) mouse = np.array([p.mouse.x, p.mouse.y]) center = np.array([width/2, height/2]) mouse -= center m = np.linalg.norm(mouse) p.fill(0) p.noStroke() p.rect(0,0,m,10) p.translate(width/2, height/2) p.strokeWeight(2) p.stroke(0) p.line(0, 0, mouse[0], mouse[1])
def drawLEDs(network): for n in network.G.nodes_iter(): pp.pushMatrix() pp.noStroke() pp.translate(*n.coords) pp.fill(pp.color(100, 100, 100)) #all nodes are grey for now pp.sphere(1) pp.popMatrix() pp.strokeWeight(3) for e in network.G.edges_iter(data=True): pp.pushMatrix() pp.stroke( pp.color(*e[2]['color']) ) (x1, y1, z1) = e[0].coords (x2, y2, z2) = e[1].coords pp.line( x1, y1, z1, x2, y2, z2 ) pp.popMatrix()
def draw(): p.background(255) # pick a random number and increase the count index = randint(0,len(randomCounts)-1) randomCounts[index] += 1 # draw a rectangle to graph results p.stroke(0); p.strokeWeight(2); p.fill(127); w = width/len(randomCounts) for x in range(0,len(randomCounts)): p.rect(x*w, height-randomCounts[x], w-1, randomCounts[x])
def draw(): p.background(255) # vector that points to the mouse location mouse = np.array([p.mouse.x, p.mouse.y], dtype=float) # vector that points to the center of the window center = np.array([width/2, height/2]) # subtract center from mouse, gives vector pointing from center to mouse mouse -= center # normalize the vector mouse /= np.linalg.norm(mouse) # multiply length mouse *= 150 # draw the resulting vector p.translate(width/2, height/2) p.strokeWeight(2) p.stroke(0) p.line(0, 0, mouse[0], mouse[1])
def display(self): p.stroke(0) p.strokeWeight(2) p.fill(127) p.ellipse(self.location.x, self.location.y, 48, 48)
def display(self): """Displays mover as circle.""" p.stroke(0) p.strokeWeight(2) p.fill(127) p.ellipse(self.location.x, self.location.y, 48, 48)
def setup(): p.size(400, 400) p.strokeWeight(10) p.stroke(255, 200)