Guest User

Untitled

a guest
Jun 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. in draw event:
  2.  
  3. if (!variable_local_exists("x1")) {
  4.     x1=room_width/2-100;
  5.     y1=room_height/2;
  6.     x2=room_width/2;
  7.     y2=room_height/2-50;
  8.     x3=room_width/2+100;
  9.     y3=room_height/2;
  10.     click=0;
  11. }
  12.  
  13. scr_3bezier(x1,y1,x2,y2,x3,y3);
  14.  
  15. x0=mouse_x;
  16. y0=mouse_y;
  17.  
  18. if (mouse_check_button_pressed(mb_left)) {
  19.     if (point_distance(x0,y0,x1,y1)<=3) {
  20.         click=1;
  21.     }
  22.     if (point_distance(x0,y0,x2,y2)<=3) {
  23.         click=2;
  24.     }
  25.     if (point_distance(x0,y0,x3,y3)<=3) {
  26.         click=3;
  27.     }
  28. }
  29.  
  30. if (click=1) { x1=x0; y1=y0; }
  31. if (click=2) { x2=x0; y2=y0; }
  32. if (click=3) { x3=x0; y3=y0; }
  33.  
  34. if (mouse_check_button_released(mb_left)) { click=0; }
  35. draw_set_color(c_red);
  36. draw_circle(x1,y1,3,0);
  37. draw_circle(x2,y2,3,0);
  38. draw_circle(x3,y3,3,0);
  39. draw_set_color(c_black);
  40.  
  41. in script scr_3bezier:
  42.  
  43. var x1,y1,x2,y2,x3,y3,xx,yy,xp,yp,t;
  44. x1=argument0;
  45. y1=argument1;
  46. x2=argument2;
  47. y2=argument3;
  48. x3=argument4;
  49. y3=argument5;
  50.  
  51. xp=x1;
  52. yp=y1;
  53.  
  54. for (t=0; t<=1; t+=0.02) {
  55. xx=2*t*(1-t)*x2+power(t,2)*(x1+x3)+x1*(1-2*t);
  56. yy=2*t*(1-t)*y2+power(t,2)*(y1+y3)+y1*(1-2*t);
  57.  
  58. draw_line(xx,yy,xp,yp);
  59. xp=xx;
  60. yp=yy;
  61. }
Add Comment
Please, Sign In to add comment