Skip to content

Instantly share code, notes, and snippets.

@manuq
Created April 3, 2014 12:03
Show Gist options
  • Save manuq/9953127 to your computer and use it in GitHub Desktop.
Save manuq/9953127 to your computer and use it in GitHub Desktop.
from math import sin, cos
from random import random
size(900,200)
speed(30)
def setup():
global cnt
cnt = 0.0
global tic
tic = 0
global tail
tail = []
def store():
x, y = MOUSEX, MOUSEY
tail.append([x, y, 90 + 10 * cos(cnt), cnt])
def draw():
global tic
if tic % 1 == 0:
store()
translate(-50,-50)
global cnt
removes = []
for i in range(len(tail)):
x, y, t, col = tail[i]
c = t * 1.0 / 100
fill(c, 0.5*cos(col), sin(col))
oval(x + sin(cnt), y + cos(cnt) - t / 4 * sin(t / 10.0) + sin(cnt), t, t)
rect(x + sin(cnt), y + cos(cnt) - t / 4 * sin(t / 10.0) + sin(cnt), t, t, 0.95)
if t < 0:
removes.append(i)
tail[i] = x, y, t-1, col
for i in removes:
del tail[i]
cnt += 0.10
tic += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment