Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "gd"
- size = 400
- im = gd.createPalette(size, size)
- assert(im)
- black = im:colorAllocate(0, 0, 0)
- im:gifAnimBegin("out.gif", true, 0)
- r = 40
- steps = 60
- angle = 2*math.pi/steps
- for i = 1, steps*2 do
- --tim = gd.create(size, size)
- --tim:paletteCopy(im)
- tim = gd.createTrueColor(size, size)
- --tim:arc(40, 40, 40, 40, 36*(i-1), 36*i, white)
- angles = {{
- angle*i,
- angle*i+2*math.pi/3,
- angle*i+4*math.pi/3,
- -angle*i+2*math.pi,
- -angle*i+4*math.pi/3,
- -angle*i+2*math.pi/3},{
- angle*i+math.pi,
- angle*i+2*math.pi/3+math.pi,
- angle*i+4*math.pi/3+math.pi,
- -angle*i+2*math.pi+math.pi,
- -angle*i+4*math.pi/3+math.pi,
- -angle*i+2*math.pi/3+math.pi}}
- table.sort(angles[1])
- table.sort(angles[2])
- for cx = -8, 12 do
- c = cx%2+1
- oy = cx%2
- for cy = -5, 9, 2 do
- points = {}
- for a = 1, #angles[c] do
- table.insert(points, {
- r*(cx+math.cos(angles[c][a]))+oy*i*2,
- r*(cy+math.sin(angles[c][a]))+oy*i*2})
- end
- w = 255-math.sqrt(math.pow(r*cx+oy*i*2-size/2, 2)+math.pow(r*cy+oy*i*2-size/2, 2))/2
- if w > 0 then
- tim:filledPolygon(points, tim:colorAllocate(w, w, w))
- end
- --tim:polygon(points, white)
- end
- end
- ti = tim:createPaletteFromTrueColor(true, 5)
- ti:gifAnimAdd("out.gif", true, 0, 0, 5, gd.DISPOSAL_NONE)
- end
- gd.gifAnimEnd("out.gif")
- print("Gif animation written to 'out.gif' file")
Advertisement
Add Comment
Please, Sign In to add comment