You are here

BezierBounce.bas



color 0,0
cls

for
n=1 to 16
append a,rnd*(xmax-20)+10
append a,rnd*(ymax-20)+10
append d,(rnd*3+1)*sgn(rnd-.5)
append d,(rnd*3+1)*sgn(rnd-.5)
next

f=rgbf(1,1,1):l1=bez(a,3)
repeat

for
n=0 to ubound(a)
k=a(n)+d(n):s=ymax
if
n%2=0:s=xmax:endif
if
(k>s) or (k<0)
d(n)=(rnd*3+1)*sgn(-d(n))
endif:a(n)=a(n)+d(n):next
l2=l1:l1=bez(a,3)
drawpoly(l2) color 0
drawpoly(l1) color 2
delay 20:until 0

func
bez(a,b)
local a1,n,m
for
m=1 to b
erase a1
append a1,a(0)
append a1,a(1)
for
n=0 to ubound(a) -5 step 2
append a1,(a(n)+3*a(n+2))/4
append a1,(a(n+1)+3*a(n+3))/4
append a1,(3*a(n+2)+a(n+4))/4
append a1,(3*a(n+3)+a(n+5))/4
next

append a1,a(ubound(a)-1)
append a1,a(ubound(a))
erase a:a=a1
next:bez=a
end
func

Comments

This makes quite a dramatic display, showing off both Bezier techniques, and the capability of SmallBASIC!

It puts the Bezier code in a function. I previously wrote a "Bezier-Pen" program which does not use a function. I will have to make test-files to compare execution times for the two techniques.

Yeah, it's pretty interesting. I should have mentioned, this and the plasmaJVSH.bas program were contributed by an anonymous code library submitter. Thanks for sharing who ever wrote these programs.

Thank you
I wrote these programs, but when i uploaded them, for some reason, it seemed like nothing happened. I guess that some glitch prevented my id from being associated with the program code.