블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
  • total
  • today
  • yesterday

Category

2007. 8. 1. 11:14 Code/NodeBox
도전장: David Hirmes - lines15 (ref. Flash Math Creativity)
원래 이걸 하려고 했는데 lines14에서 조금 더 응용된 것이라 우선 lines14를 먼저 해 보았던 것이다.

5초만에 끝. ^^

s = 300
n = 6

size(s, s)
speed(200)

from math import cos, sin, acos, sqrt

def setup():  
    global x
    global y
    global f    
    global g
   
    x = range(s)
    y = range(s)   
    for i in range(s):
        x[i] = random(s)
        y[i] = random(s)

    f = 0
    g = 0


def draw():
    global x
    global y   
    global f   
    global g

    dx = x[f+1] - x[f]
    dy = y[f+1] - y[f]
       
    dd = dx**2 + dy**2
    d = sqrt(dd)
    l = g * d/n
   
    da = acos(dx/d)

    if dy < 0:
        da = -da
        ph = 6.28
    else:
        ph = 0

    a = g * (da+ph)/n
   
    for k in range(f):
        stroke(0)
        line(x[k], y[k], x[k+1], y[k+1])       
        line(x[f], y[f], x[f]+l*cos(a), y[f]+l*sin(a))
       
       
    g += 1
       
    if g > n:
        g = 0
        f += 1
       
    if f > s-1:
        f = 0

'Code > NodeBox' 카테고리의 다른 글

simple oscillation test  (0) 2007.08.26
David Hirmes - lines14  (0) 2007.07.31
David Hirmes - lines02  (0) 2007.07.25
David Hirmes - blobs01  (0) 2007.07.18
splash_class_multi  (0) 2007.07.13
posted by maetel