• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 bezier and cubic curves nitrofurano Senior Member Posts: 366 Threads: 186 Joined: Sep 2011 Reputation: 0 10-25-2011, 04:33 PM finally i coded some snipets - two of them are about drawing bezier and cubic curves - btw, if someone can help them being faster, or part of the library, be welcome! beziercurve.bas Code:```dim x0,y0,x1,y1,x2,y2,x3,y3 as float dim stpv,xi,xo,yi,yo,ir,i as float dim xr1,yr1,xr2,yr2 as float dim xsn,ycs as float dim xa,ya,xb,yb,xc,yc as float dim tw,t as float x0=20:y0=30:x1=50:y1=80:x2=150:y2=40:x3=110:y3=10 xa=(x3)-(3*x2)+(3*x1)-(x0) ya=(y3)-(3*y2)+(3*y1)-(y0) xb=(3*x2)-(6*x1)+(3*x0) yb=(3*y2)-(6*y1)+(3*y0) xc=(3*x1)-(3*x0) yc=(3*y1)-(3*y0) stpv=32 for tw=0 to stpv   t=tw/stpv   x=(((((xa*t)+xb)*t)+xc)*t)+x0   y=(((((ya*t)+yb)*t)+yc)*t)+y0   if tw=0 then:xo=x:yo=y:end if   plot xo,yo:draw x-xo,y-yo   :'- line (xo,yo,x,y):   xo=x:yo=y next pause 0``` cubiccurve.bas Code:```dim x0,y0,x1,y1,x2,y2,x3,y3 as float dim stpv,xi,xo,yi,yo,ir,i as float dim xr1,yr1,xr2,yr2 as float dim xsn,ycs as float x0=20:y0=30:x1=50:y1=80:x2=150:y2=40 xr1=x1-x0:yr1=y2-y1 x3=x0+x2-x1:y3=y0+y2-y1 xr2=x2-x1:yr2=y3-y2 stpv=32 for i=0 to stpv   ir=i*(1.570796/stpv)   xsn=(xr1*sin(ir))-(xr2*cos(ir))   ycs=(yr1*(cos(ir)*-1))-(yr2*sin(ir))   xi=x3+xsn:yi=y3+ycs   if i=0 then:xo=xi:yo=yi:end if   if i<>0 then:     plot xo,yo:draw xi-xo,yi-yo  :'- line (xo,yo,xi,yi)     end if   xo=xi   yo=yi   next i pause 0``` circlefill.bas Code:```dim x,y,r,xl as ubyte dim yd as float x=50:y=60:r=40 for yd=0 to r   xl=int((sin(acs(yd/r)))*r)   plot x-xl,y+yd:draw xl*2,0   if yd<>0 then:plot x-xl,y-yd:draw xl*2,0:end if   next yd pause 0``` boxfill.bas Code:```dim x1,y1,x2,y2 as integer x1=20:y1=30:x2=50:y2=80 for y=y1 to y2   plot x1,y:draw x2-x1,0   next y pause 0``` box.bas Code:```dim x1,y1,x2,y2 as integer x1=20:y1=30:x2=50:y2=80 plot x1,y1 draw x2-x1,0 draw 0,y2-y1 draw x1-x2,0 draw 0,y1-y2 pause 0``` line.bas Code:```dim x1,y1,x2,y2 as integer x1=20:y1=30:x2=50:y2=80 plot x1,y1 draw x2-x1,y2-y1 pause 0``` « Next Oldest | Next Newest »