Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from wand.image import Image
- from wand.drawing import Drawing
- from wand.color import Color
- import math
- def drawcircle(cx, cy, r, ns, c):
- draw.fill_color = Color(c)
- sa = 2*math.pi/ns
- for s in xrange(ns):
- x1 = cx + r*math.cos(s*sa)
- y1 = cy + r*math.sin(s*sa)
- x2 = cx + r*math.cos((s+1)*sa)
- y2 = cy + r*math.sin((s+1)*sa)
- draw.line((x1, y1), (x2, y2))
- nf = 60
- fa = 2*math.pi/nf
- with Image(width=400, height=400) as img:
- draw = Drawing()
- drawcircle(200, 200, 100, 100, 'black')
- circle1 = draw
- circles = []
- for f in xrange(nf):
- frm = Image(width=400, height=400)
- circle1(frm)
- draw = Drawing()
- cx = 200 + 100*math.cos(f*fa)
- cy = 200 + 100*math.sin(f*fa)
- drawcircle(cx, cy, 100, 50, 'black')
- draw(frm)
- for circle in circles:
- circle(frm)
- if f % (nf/6) == 0:
- circles.append(draw)
- img.sequence.append(frm)
- img.sequence[len(img.sequence)-1].delay = 1
- print("frame %d" % f)
- del img.sequence[0]
- img.format = 'gif'
- img.save(filename="test.gif")
Advertisement
Add Comment
Please, Sign In to add comment