Meditation Bot
Meditation Bot Code
""" Meditation Bot """ diameter = 400 centerX = diameter/2 centerY = diameter/2 boxSize = 120 balls = [(100,20,-2.5,3,20),(120,50,-3.5,-3,10),(70,20,-3.5,-3,10), (190,50,-1,-3,20),(300,50,-5,-3,10),(330,100,-2,-3,10)] def setup(): size(diameter, diameter+100) colorMode(RGB, 1) def draw(): #style rectMode(CENTER) ellipseMode(CENTER) noStroke() boxsize = 100 angle = PI * sin(frameCount * 0.02) background(1,.1) #body fill(1,.1,.6,.6) rect(centerX,centerY+50,boxSize,boxSize) #head fill(1,.1,.6,.6) ellipse(centerX,centerY-boxSize+50, boxSize,boxSize) #leg fill(1,.1,.6,.6) rect(centerX-45,centerY+170,boxSize/4,boxSize) rect(centerX+45,centerY+170,boxSize/4,boxSize) position1x = centerX - boxsize/2 position1y = centerY - boxsize/2 +50 position2x = centerX + boxsize/2 position2y = centerY - boxsize/2 +50 # Right Arms drawArm(position2x, position2y, +1, angle - TWO_PI * .5) # Left Arms drawArm(position1x, position1y, -1, angle -TWO_PI * .5) #ball fill(0,.5,.8,.3) for i in range(len(balls)): x,y,dx,dy,r = balls[i] x += dx if constrain(x,r,diameter-r) != x: dx = -dx y += dy if constrain(y,r,diameter+100-r) != y: dy = -dy balls[i] = x,y,dx,dy,r ellipse(x,y,r,r) saveFrame("MinsooBot.gif") def drawArm(xpos, ypos, direction, angle = -TWO_PI /2): pushMatrix() translate(xpos, ypos) scale(direction, 1) rotate(angle) rectMode(CORNER) rect(0, 0, 20, 150) popMatrix()