在 Processing 中连续旋转对象矩阵
Continuously spin a matrix of objects in Processing
我有一堆线可以画一个复合圆。我想让这个复合圆连续旋转但无法弄清楚。为了进一步解释我想要什么,它有点像加载微调器。
def setup():
size(640, 640)
frameRate(30)
def draw():
background(0)
stroke(100, 100, 100)
strokeWeight(4)
translate(width/2, height/2)
# I want to rotate/make this composite circle spin continuously
make_circle()
def make_circle():
inner_radius = width / 8
line_length = width / 3
rx = sqrt(2) * inner_radius
ry = rx
steps = 10
pushMatrix()
for dtheta in range(0, 360, steps):
dtheta = radians(dtheta)
coss = cos(dtheta)
sinn = sin(dtheta)
line(inner_radius * coss, inner_radius * sinn, line_length * coss, line_length * sinn)
popMatrix()
你需要rotate
the complete shape. Add an angle
variable in global namespace. Increment the angle
inn every frame and rotate
角度的形状(默认角度的单位是弧度):
angle = 0
def draw():
global angle
background(0)
stroke(100, 100, 100)
strokeWeight(4)
translate(width/2, height/2)
rotate(radians(angle))
angle += 1
make_circle()
我有一堆线可以画一个复合圆。我想让这个复合圆连续旋转但无法弄清楚。为了进一步解释我想要什么,它有点像加载微调器。
def setup():
size(640, 640)
frameRate(30)
def draw():
background(0)
stroke(100, 100, 100)
strokeWeight(4)
translate(width/2, height/2)
# I want to rotate/make this composite circle spin continuously
make_circle()
def make_circle():
inner_radius = width / 8
line_length = width / 3
rx = sqrt(2) * inner_radius
ry = rx
steps = 10
pushMatrix()
for dtheta in range(0, 360, steps):
dtheta = radians(dtheta)
coss = cos(dtheta)
sinn = sin(dtheta)
line(inner_radius * coss, inner_radius * sinn, line_length * coss, line_length * sinn)
popMatrix()
你需要rotate
the complete shape. Add an angle
variable in global namespace. Increment the angle
inn every frame and rotate
角度的形状(默认角度的单位是弧度):
angle = 0
def draw():
global angle
background(0)
stroke(100, 100, 100)
strokeWeight(4)
translate(width/2, height/2)
rotate(radians(angle))
angle += 1
make_circle()