|
Post by davos1 on Feb 25, 2009 14:53:40 GMT -5
Hi, some free code I found about bezier curves... (for drawing, animation,camera movements, letters, etc), and adapted it to runbasic in 2d..
graphic #g, 800, 600 #g fill("yellow") #g color("black")
a= bezier(0,0,100,700,500,200,800,600, #g)
rem render #g 'here you could render the object again...
function bezier(x1,y1,x2,y2,x3,y3,x4,y4,#myDrawing) rem x1,y1=initial point, x2,y2=control point of x1,y2. x3,y3=control point of x4,y4 x4,y4=final points rem to move the center coordinates rem currently 0,0 means left,top of the graphic cXI=0 cYI=0
a = 1 b = 1.0 - a
rem size of the curve in pixels, you could reduce the resolution if the curve is smaller... for i = 1 to 2500 step 1 x = x1*a^3 + x2*3*a^2*b + x3*3*a*b^2 + x4*b^3 y = y1*a^3 + y2*3*a^2*b + y3*3*a*b^2 + y4*b^3 #myDrawing place(cXI+x,cYI+y) #myDrawing set(cXI+x,cYI+y) rem a- 1/number of times of the cycle i a = a - 0.0004 b = 1.0 - a next i render #myDrawing
end function
;D Stefan: corrected the preformatted text tags, make sure there is no space in between the brackets
|
|