Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. if(drawDir.Q == 1){
  2. //x ghost line
  3. terminalX = getCursorPosition(tempCanvas, event)[0];
  4. ghostLine(point.x1, point.y1, terminalX, point.y1, true);
  5. rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 0);
  6.  
  7. var terminalSideLength = terminalX - point.x1;
  8. var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
  9.  
  10. var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
  11. var angle = degInRadians * 180 / Math.PI;
  12. console.log(angle);
  13. }
  14. else if(drawDir.Q == 2){
  15. terminalX = (point.x1 - getCursorPosition(tempCanvas, event)[0]) + point.x1;
  16. ghostLine(point.x1, point.y1, terminalX, point.y1, true);
  17. rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 0);
  18.  
  19. terminalY = (getCursorPosition(tempCanvas, event)[1] - point.y1) + point.y1;
  20. ghostLine(point.x1, point.y1, point.x1, terminalY, true);
  21. rayArrow(point.x1, terminalY, 4, 0.5, t_ctx, 90);
  22.  
  23. var terminalSideLength = terminalX - point.x1;
  24. var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
  25.  
  26. var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
  27. var angle = degInRadians * 180 / Math.PI;
  28. console.log(180 - angle);
  29. }
  30. else if(drawDir.Q == 3){
  31. terminalX = (point.x1 - getCursorPosition(tempCanvas, event)[0]) + point.x1;
  32. ghostLine(point.x1, point.y1, terminalX, point.y1, true);
  33. rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 0);
  34.  
  35. terminalY = point.y1 - (getCursorPosition(tempCanvas, event)[1] - point.y1);
  36. ghostLine(point.x1, point.y1, point.x1, terminalY, true);
  37. rayArrow(point.x1, terminalY, 4, 0.5, t_ctx, 90);
  38.  
  39. terminalNegX = point.x1 - (point.x1 - getCursorPosition(tempCanvas, event)[0]);
  40. ghostLine(point.x1, point.y1, terminalNegX, point.y1, true);
  41. rayArrow(terminalNegX, point.y1, 4, 0.5, t_ctx, 180);
  42.  
  43. var terminalSideLength = terminalX - point.x1;
  44. var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
  45.  
  46. var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
  47. var angle = degInRadians * 180 / Math.PI;
  48. console.log(180 + angle);
  49. }
  50. else if(drawDir.Q == 4){
  51. terminalX = (point.x1 - getCursorPosition(tempCanvas, event)[0]) + point.x1;
  52. ghostLine(point.x1, point.y1, terminalX, point.y1, true);
  53. rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 180);
  54.  
  55. terminalY = point.y1 - (getCursorPosition(tempCanvas, event)[1] - point.y1);
  56. ghostLine(point.x1, point.y1, point.x1, terminalY, true);
  57. rayArrow(point.x1, terminalY, 4, 0.5, t_ctx, 90);
  58.  
  59. terminalNegX = point.x1 - (point.x1 - getCursorPosition(tempCanvas, event)[0]);
  60. ghostLine(point.x1, point.y1, terminalNegX, point.y1, true);
  61. rayArrow(terminalNegX, point.y1, 4, 0.5, t_ctx, 0);
  62.  
  63. terminalNegY = point.y1 - (point.y1 - getCursorPosition(tempCanvas, event)[1]);
  64. ghostLine(point.x1, point.y1, point.x1, terminalNegY, true);
  65. rayArrow(point.x1, terminalNegY, 4, 0.5, t_ctx, 270);
  66.  
  67. var terminalSideLength = terminalX - point.x1;
  68. var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
  69.  
  70. var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
  71. var angle = degInRadians * 180 / Math.PI;
  72. console.log(180 + angle);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement