def simple_multi_modal(): source, text = animation_q.get_nowait() # non-blocking check for items in animation_q. # If queue is empty a Queue.Empty exception is raised. if source == 'gesture': p.fill(0, 102, randint(50,150)) p.textSize(48) elif source == 'speech': p.fill(102, randint(50,150), 0) p.textSize(32) else: pass p.text(text, randint(50,550), randint(50,550))
def labelDisplay(emotionCount): textSize(12) fill(120, 225, 255) text("Sadness: {0}".format(emotionCount[0]), 5, 15) fill(255, 167, 0) text("Joy: {0}".format(emotionCount[1]), 5, 30) fill(0, 0, 0) text("Fear: {0}".format(emotionCount[2]), 5, 45) fill(141, 85, 36) text("Disgust: {0}".format(emotionCount[3]), 5, 60) fill(214, 45, 32) text("Anger: {0}".format(emotionCount[4]), 5, 75)
def simple_multi_modal(): source, recognized_input = animation_q.get_nowait() # non-blocking check for items in animation_q. # If queue is empty a Queue.Empty exception is raised. # data read from queue is a tuple of strings: (source, recognized_input) if source == 'gesture': p.fill(0, 102, randint(50, 150)) p.textSize(48) elif source == 'speech': p.fill(102, randint(50, 150), 0) p.textSize(32) else: pass p.text(recognized_input, randint(50, 550), randint(50, 550))
def draw(): p.background(255) liquid.display() for mover in movers: if liquid.contains(mover): dragForce = liquid.drag(mover) mover.applyForce(dragForce) gravity = p.PVector(0, 0.1 * mover.mass) mover.applyForce(gravity) mover.update() mover.checkEdges() mover.display() p.fill(0) p.text("click mouse to reset", 10, 30)
def draw(self, millis): background(51) items = self.ring.get() (x,self.y) = (0, self.y_step * len(items)) self.update(millis) for item in items: try: if item is not None: fill(item.color) text(item.text, x, self.y) else: text("Something bad happened", x, self.y) except UnicodeDecodeError: text("Unsupported Language Tweeted", x, self.y) self.y-= self.y_step
def draw(self): stroke(53) text(self.char, self.x, self.y, U*5, U*5) self.tick()