Beispiel #1
0
def branches(height):
	height *= 0.66

	# draw left and right branch
	for angle in [-0.5, 0.5]:
		p.pushMatrix()
		p.rotate(angle)
		p.line(0, 0, 0, -height)
		p.translate(0, -height)
		p.popMatrix()
Beispiel #2
0
def drag_segment(i, head_x, head_y):
	# find the inclination of a segment with respect to X axis
	angle = math.atan2(head_y - y[i], head_x - x[i])
	# find tail position by rotating a segment around its head point
	x[i] = head_x - math.cos(angle) * LENGTH
	y[i] = head_y - math.sin(angle) * LENGTH

	# draw a segment (tail to head)
	p.pushMatrix()
	p.translate(x[i], y[i])
	p.rotate(angle)
	p.line(0, 0, LENGTH, 0)
	p.popMatrix()
Beispiel #3
0
def branches(height, angle):
	height *= 0.66

	# finish branching when height is small
	if height < 3:
		return

	# draw left and right branch
	for angle in [-angle, angle]:
		p.pushMatrix()
		p.rotate(angle)
		p.line(0, 0, 0, -height)
		p.translate(0, -height)
		branches(height, angle)
		p.popMatrix()
Beispiel #4
0
def rotate(f):
	p.translate(0, 240)
	p.rotate(-math.pi / 2)
Beispiel #5
0
def rot45(f):
	p.rotate(-math.pi / 4)
	p.scale(1 / math.sqrt(2))
Beispiel #6
0
def update():
    """
    wrap arcball update and rotation as a local function
    """
    theta,  x,  y,  z = arcball.update()
    pp.rotate(theta,  x,  y,  z)    
Beispiel #7
0
	def wrapped_f():
		p.pushMatrix()
		p.translate(0, 240)
		p.rotate(-math.pi / 2)
		f()
		p.popMatrix()
Beispiel #8
0
#!/usr/bin/evn python
# coding=utf-8
"""
Star.

"""
import math
import pyprocessing as p


p.size(400, 400)
p.colorMode(p.HSB, 360, 100, 100, 100)
p.noStroke()

p.background(0)
# TODO: try to change the alpha value
p.fill(0, 100, 100, 40)

# shift the (0, 0) point
p.translate(200, 200)

# TODO: try to change the number of triangles
for i in range(10):
	# rotate around (0, 0) by 1/10th of a full angle
	p.rotate(2 * math.pi / 10)
	p.triangle(0, -200, 100, 100, -100, 100)

p.run()