Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- in draw event:
- if (!variable_local_exists("x1")) {
- x1=room_width/2-100;
- y1=room_height/2;
- x2=room_width/2;
- y2=room_height/2-50;
- x3=room_width/2+100;
- y3=room_height/2;
- click=0;
- }
- scr_3bezier(x1,y1,x2,y2,x3,y3);
- x0=mouse_x;
- y0=mouse_y;
- if (mouse_check_button_pressed(mb_left)) {
- if (point_distance(x0,y0,x1,y1)<=3) {
- click=1;
- }
- if (point_distance(x0,y0,x2,y2)<=3) {
- click=2;
- }
- if (point_distance(x0,y0,x3,y3)<=3) {
- click=3;
- }
- }
- if (click=1) { x1=x0; y1=y0; }
- if (click=2) { x2=x0; y2=y0; }
- if (click=3) { x3=x0; y3=y0; }
- if (mouse_check_button_released(mb_left)) { click=0; }
- draw_set_color(c_red);
- draw_circle(x1,y1,3,0);
- draw_circle(x2,y2,3,0);
- draw_circle(x3,y3,3,0);
- draw_set_color(c_black);
- in script scr_3bezier:
- var x1,y1,x2,y2,x3,y3,xx,yy,xp,yp,t;
- x1=argument0;
- y1=argument1;
- x2=argument2;
- y2=argument3;
- x3=argument4;
- y3=argument5;
- xp=x1;
- yp=y1;
- for (t=0; t<=1; t+=0.02) {
- xx=2*t*(1-t)*x2+power(t,2)*(x1+x3)+x1*(1-2*t);
- yy=2*t*(1-t)*y2+power(t,2)*(y1+y3)+y1*(1-2*t);
- draw_line(xx,yy,xp,yp);
- xp=xx;
- yp=yy;
- }
Add Comment
Please, Sign In to add comment