bezier-curve {
init:
float x0=real(@z0)
float y0=imag(@z0)
float x1=real(@z1)
float y1=imag(@z1)
float x2=real(@z2)
float y2=imag(@z2)
float x3=real(@z3)
float y3=imag(@z3)
float cx=3*(x1-x0)
float bx=3*(x2-x1)-cx
float ax=x3-x0-cx-bx
float cy=3*(y1-y0)
float by=3*(y2-y1)-cy
float ay=y3-y0-cy-by
float r=0.0
float x=0.0
float y=0.0
float u=0.0
float v=0.0
float t=0.0
float rmin=1.0e20
loop:
u=real(#z)
v=imag(#z)
t=0.0
while(t<=1.0)
x=((ax*t+bx)*t+cx)*t+x0
y=((ay*t+by)*t+cy)*t+y0
r=(x-u)*(x-u)+(y-v)*(y-v)
if(r<rmin)
rmin=r
endif
t=t+@dt
endwhile
final:
#index=rmin^@nexp
default:
title="Bezier Curve"
helpfile="lkm-help\lkm-bezier.html"
param z0
caption="1st anchor point"
default=(1.0,0.0)
hint="Curve starts at this point."
endparam
param z1
caption="1st control point"
default=(1.0,1.0)
hint="Influences the shape of the curve."
endparam
param z2
caption="2nd control point"
default=(0.0,0.0)
hint="Influences the shape of the curve."
endparam
param z3
caption="2nd anchor point"
default=(0.0,1.0)
hint="Curve ends at this point."
endparam
param dt
caption="step size"
default=0.1
hint="Decrease for smoother line, increase \
to see dots. Should be between 0 & 1."
min=0.0
max=1.0
endparam
param nexp
caption="power"
default=0.1
min=0.0
hint="Decrease to make thinner lines. Use \
with 'minimum distance' coloring."
endparam
}
此代码,经UF中验证,没问题。此特效一直没整成功,今天去除另三个不很美的开关项,打算重新整这特效,力争整出原样。我干了一遍,结果不对。打算换一个方法来弄。 |