def draw(self): pyp.pushMatrix() pyp.noStroke() pyp.fill(self.fill_color) pyp.translate(*self.position) self.draw_poly() pyp.popMatrix()
def draw(): sd = 60 # standard deviation mean = width/2 # mean xloc = gauss(mean, sd) # gets gaussian random number p.noStroke() p.fill(0,10) p.ellipse(xloc, height/2, 16,16) # draw ellipse at our random location
def setup(): ''' Invoked exactly once by pyprocessing.run(). ''' p.size(600,600,caption="Smart Home Multi-Modal Input") p.ellipseMode(p.CENTER) p.noStroke() start_thread(recognition, ('gesture',animation_q,)) start_thread(speech_recognition, (animation_q,))
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.noStroke() p.fill(255,10) p.rect(0,0,width,height) # add current speed to location location.add(velocity) if location.x > width or location.x < 0: velocity.x *= -1 if location.y > height or location.y < 0: velocity.y *= -1 # display circle at location p.stroke(0) p.fill(175) p.ellipse(location.x, location.y, 16, 16)
def setup(): p.size(400, 400) p.rectMode(p.CENTER) p.noStroke()
def display(self): p.noStroke() p.fill(50) p.rect(self.x, self.y, self.w, self.h)
#!/usr/bin/evn python # coding=utf-8 """ Recursion. """ import pyprocessing as p p.size(400, 400) p.noStroke() def circle(x, radius, level): p.fill(126 * level / 4) p.ellipse(x, 200, radius * 2, radius * 2) if level > 1: circle(x - 0.5 * radius, 0.5 * radius, level - 1) circle(x + 0.5 * radius, 0.5 * radius, level - 1) # TODO: try more/less levels circle(200, 200, 6) p.run()
def setup(): p.size(600, 200) p.colorMode(p.HSB, 360, 100, 100) p.noStroke() add(random.randint(0, 600), random.randint(0, 200))
def setup(): p.size(400, 400) p.colorMode(p.HSB, 360, 100, 100) p.fill(30, 100, 100) p.noStroke() p.noLoop()
def setup(): p.size(640, 360) p.noStroke()