GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2016-12-08 11:41:12

omar
Member
Registered: 2016-06-23
Posts: 8

draw_curve(general)

draw a Bézier curve with n number of points

Expand//draw_curve(prec,x0,y0,x1,y1...,xn,yn)

var a,b,i,xx,yy,px,py,prec,num;
xx=argument1;
yy=argument2;
prec=1/argument0;
num=(argument_count-1) div 2;

for(i=prec; i<=1; i+=prec)
{
    for (a=0; a<num; a+=1)
    {
        px[a]=argument[a*2+1];
        py[a]=argument[a*2+2];
    }
    
    for (a=num-1; a>0; a-=1)
    for (b=0; b<a; b+=1)
    {
        px[b]+=(px[b+1]-px[b])*i;
        py[b]+=(py[b+1]-py[b])*i;
    }
    
    draw_line(xx,yy,px[0],py[0]);
    xx=px[0]; yy=py[0];
}

example:

Expanddraw_curve(40,200,200,mouse_x,mouse_y,400,200);

Last edited by omar (2016-12-08 11:44:59)

Offline

Board footer

Powered by FluxBB