2007. 7. 9. 19:09
Code/NodeBox
1. 언급하였듯 i=1일 때가 문제였으므로, 그릴 때 i=1부터 그리게 했더니 해결되었다.
2. 마우스가 움직이는 동안 따라오는 최초의 사각형(t번째)에 t-1번째 사각형이 더해지는 현상을 없애기 위해 u[i]의 매개변수를 조정해 주면 된다는 것을 알았다.
가시적인 결과는 원하던 대로 나왔으나, 뭔가... 깔끔한 코드가 아니라는 생각이 든다.
2. 마우스가 움직이는 동안 따라오는 최초의 사각형(t번째)에 t-1번째 사각형이 더해지는 현상을 없애기 위해 u[i]의 매개변수를 조정해 주면 된다는 것을 알았다.
size(400,400)
speed(100)
def setup():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
t=20 #term
mx=range(t)
my=range(t)
for n in range(t):
mx[n]=-WIDTH
my[n]=-HEIGHT
#x=range(8)
#y=range(8)
x0=range(t)
y0=range(t)
x1=range(t)
y1=range(t)
x2=range(t)
y2=range(t)
x3=range(t)
y3=range(t)
x4=range(t)
y4=range(t)
x5=range(t)
y5=range(t)
x6=range(t)
y6=range(t)
x7=range(t)
y7=range(t)
u=range(t)
p=range(t)
d=20 #distance
s=2 #initial size
r=0.99 #ratio of size decreasing
def draw():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
background(0,0,1)
fill(1)
for i in range(t-1):
mx[i]=mx[i+1]
my[i]=my[i+1]
mx[t-1]=MOUSEX
my[t-1]=MOUSEY
rectc(mx[i],my[i],s,s)
for i in range(t):
u[i]=(t-1-i)*2 ##to controll the stages of popping
p[i]=-i ##to controll the sizes of popping
if (i>=1) & ((mx[i]-mx[i-1])==0):
u[i]=0
x0[i]=mx[i]+u[i]
y0[i]=my[i]
x1[i]=mx[i]+u[i]
y1[i]=my[i]+u[i]
x2[i]=mx[i]
y2[i]=my[i]+u[i]
x3[i]=mx[i]-u[i]
y3[i]=my[i]+u[i]
x4[i]=mx[i]-u[i]
y4[i]=my[i]
x5[i]=mx[i]-u[i]
y5[i]=my[i]-u[i]
x6[i]=mx[i]
y6[i]=my[i]-u[i]
x7[i]=mx[i]+u[i]
y7[i]=my[i]-u[i]
if i>0:
rectc(x0[i], y0[i], s*(r**p[i]),s*(r**p[i]))
rectc(x1[i], y1[i], s*(r**p[i]),s*(r**p[i]))
rectc(x2[i], y2[i], s*(r**p[i]),s*(r**p[i]))
rectc(x3[i], y3[i], s*(r**p[i]),s*(r**p[i]))
rectc(x4[i], y4[i], s*(r**p[i]),s*(r**p[i]))
rectc(x5[i], y5[i], s*(r**p[i]),s*(r**p[i]))
rectc(x6[i], y6[i], s*(r**p[i]),s*(r**p[i]))
rectc(x7[i], y7[i], s*(r**p[i]),s*(r**p[i]))
def rectc(xc,yc,w,h):
x=xc-w/2
y=yc-h/2
rect(x,y,w,h)
speed(100)
def setup():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
t=20 #term
mx=range(t)
my=range(t)
for n in range(t):
mx[n]=-WIDTH
my[n]=-HEIGHT
#x=range(8)
#y=range(8)
x0=range(t)
y0=range(t)
x1=range(t)
y1=range(t)
x2=range(t)
y2=range(t)
x3=range(t)
y3=range(t)
x4=range(t)
y4=range(t)
x5=range(t)
y5=range(t)
x6=range(t)
y6=range(t)
x7=range(t)
y7=range(t)
u=range(t)
p=range(t)
d=20 #distance
s=2 #initial size
r=0.99 #ratio of size decreasing
def draw():
global mx
global my
global t
global x0
global y0
global x1
global y1
global x2
global y2
global x3
global y3
global x4
global y4
global x5
global y5
global x6
global y6
global x7
global y7
global d
global s
global r
global u
global p
background(0,0,1)
fill(1)
for i in range(t-1):
mx[i]=mx[i+1]
my[i]=my[i+1]
mx[t-1]=MOUSEX
my[t-1]=MOUSEY
rectc(mx[i],my[i],s,s)
for i in range(t):
u[i]=(t-1-i)*2 ##to controll the stages of popping
p[i]=-i ##to controll the sizes of popping
if (i>=1) & ((mx[i]-mx[i-1])==0):
u[i]=0
x0[i]=mx[i]+u[i]
y0[i]=my[i]
x1[i]=mx[i]+u[i]
y1[i]=my[i]+u[i]
x2[i]=mx[i]
y2[i]=my[i]+u[i]
x3[i]=mx[i]-u[i]
y3[i]=my[i]+u[i]
x4[i]=mx[i]-u[i]
y4[i]=my[i]
x5[i]=mx[i]-u[i]
y5[i]=my[i]-u[i]
x6[i]=mx[i]
y6[i]=my[i]-u[i]
x7[i]=mx[i]+u[i]
y7[i]=my[i]-u[i]
if i>0:
rectc(x0[i], y0[i], s*(r**p[i]),s*(r**p[i]))
rectc(x1[i], y1[i], s*(r**p[i]),s*(r**p[i]))
rectc(x2[i], y2[i], s*(r**p[i]),s*(r**p[i]))
rectc(x3[i], y3[i], s*(r**p[i]),s*(r**p[i]))
rectc(x4[i], y4[i], s*(r**p[i]),s*(r**p[i]))
rectc(x5[i], y5[i], s*(r**p[i]),s*(r**p[i]))
rectc(x6[i], y6[i], s*(r**p[i]),s*(r**p[i]))
rectc(x7[i], y7[i], s*(r**p[i]),s*(r**p[i]))
def rectc(xc,yc,w,h):
x=xc-w/2
y=yc-h/2
rect(x,y,w,h)
가시적인 결과는 원하던 대로 나왔으나, 뭔가... 깔끔한 코드가 아니라는 생각이 든다.
'Code > NodeBox' 카테고리의 다른 글
splash_class (0) | 2007.07.13 |
---|---|
progress_class (0) | 2007.07.12 |
popping_1.0 (수정 중) (0) | 2007.07.06 |
popping_0.0 (0) | 2007.07.06 |
storing_test (0) | 2007.07.05 |