Hello,
Once again, thank you for being so helpful.
Enjoy the day.
Best.
Robert
At 50 years of age I have made a commitment to myself to learn new skills. I am presently learning Max MSP and after seeing the geometric beauty of DrawBot I have decided to make it my second learning challenge for the year. I am a rookie so please be kind when responding.
Hello,
Once again, thank you for being so helpful.
Enjoy the day.
Best.
Robert
Hello All,
A quick question, if I want to change my existing star properties to font properties, what might be the approach?
I have attached my code for comment.
def star(x, y, n, r1, r2):
pts = []
for i in range(n * 2):
a = i * pi / n
r = r2 if i % 2 else r1
pts.append((x + r * sin(a), y + r * cos(a)))
polygon(*pts)
CANVAS = 500
SQUARESIZE = 158
NSQUARES = 50
SQUAREDIST = 6
width = NSQUARES * SQUAREDIST
NFRAMES = 50
for frame in range(NFRAMES):
newPage(CANVAS, CANVAS)
frameDuration(1/20)
fill(0)
rect(0, 0, CANVAS, CANVAS)
phase = 2 * pi * frame / NFRAMES
startAngle = 90 * sin(phase)
endAngle = 90 * sin(phase + 0.5 * pi)
translate(CANVAS/2 - width / 2, CANVAS/2)
fill(1)
stroke(0)
for i in range(NSQUARES + 1):
f = i / NSQUARES
save()
translate(i * SQUAREDIST, 0)
scale(0.7, 1)
rotate(startAngle + f * (endAngle - startAngle))
star(0, 0, 5, SQUARESIZE, SQUARESIZE * 0.5)
restore()
saveImage("StackOfStars.gif")
Thank you.
Robert
Hello gferreira,
Thank you so much the reply has been very helpful. I can see that I was thinking too much about modifying all areas of the code instead of changing a small component.
Enjoy the day.
Best.
Robert
Hi All,
I am now totally stuck:
CANVAS = 1440
NFRAMES = 1
for frame in range(NFRAMES):
newPage(CANVAS, CANVAS)
frameDuration(1/20)
fill(0)
rect(0, 0, CANVAS, CANVAS)
phase = 2 * pi * frame / NFRAMES
startAngle = 90 * sin(phase)
endAngle = 90 * sin(phase + 0.5 * pi)
translate(CANVAS/2, CANVAS/2)
fill(1)
stroke(0)
for i in range(20):
save()
translate(i * 10)
scale(1.1)
rotate(380)
def star(x, y, n, r1, r2):
pts = []
for i in range(n * 2):
a = i * pi / n
r = r2 if i % 2 else r1
pts.append((x + r * sin(a), y + r * cos(a)))
polygon(*pts)
star(1, -95, 5, 450, 260)
restore()
saveImage("StarTest.gif")
Any help would be very much appreciated
Best,
Robert
@gferreira
Hi. That is exactly what I was hoping to achieve. Hopefully I can make this work.
Best.
Robert
Hi All,
Having a ball learning drawbot so thanks to everyone who has been involved in the development process to date. Recently I been playing around with the source code for one of Just Van Rossum's StackoSquares animations. That said, I have a question, in order to change the object from multiple squares to multiple five point stars, is the solution simply changing the square object to a star object. If so how would I write the star object code. Very new to coding so any help would be gratefully appreciated.
Best.
Robert
PS: The code is below this line of type.
CANVAS = 500
SQUARESIZE = 158
NSQUARES = 50
SQUAREDIST = 6
width = NSQUARES * SQUAREDIST
NFRAMES = 50
for frame in range(NFRAMES):
newPage(CANVAS, CANVAS)
frameDuration(1/20)
fill(0)
rect(0, 0, CANVAS, CANVAS)
phase = 2 * pi * frame / NFRAMES # angle in radians
startAngle = 90 * sin(phase)
endAngle = 90 * sin(phase + 0.5 * pi)
translate(CANVAS/2 - width / 2, CANVAS/2)
fill(1)
stroke(0)
for i in range(NSQUARES + 1):
f = i / NSQUARES
save()
translate(i * SQUAREDIST, 0)
scale(0.7, 1)
rotate(startAngle + f * (endAngle - startAngle))
rect(-SQUARESIZE/2, -SQUARESIZE/2, SQUARESIZE, SQUARESIZE)
restore()
saveImage("StackOfSquares.gif")