Code/NodeBox

storing_test

maetel 2007. 7. 5. 16:54
프로세싱 홈피에서 다음 예제를 발견!

Storing Input.
Move the mouse across the screen to change the position of the circles. The positions of the mouse are recorded into an array and played back every frame. Between each frame, the newest value are added to the end of each array and the oldest value is deleted. (Updated 21 August 2002)

이렇게 적용!

size(200,200)
speed(100)

def setup():
    global x
    global y
    global t
    
    t=10
    x=range(t)
    y=range(t)  
   
    for t in range(10):
        x[t]=-100
        y[t]=-100
      
    
def draw():
    global x
    global y
    global t

    for i in range(t-1):
        x[i]=x[i+1]
        y[i]=y[i+1]
        
        x[t-1]=MOUSEX
        y[t-1]=MOUSEY
    
    for i in range(t):    
        rect(x[i],y[i],10,10)


#x, y range의 초기값이 자동으로 설정되어 있어서 발생하는 원치않은 이미지를 size 밖으로 빼준다.