Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(drawDir.Q == 1){
- //x ghost line
- terminalX = getCursorPosition(tempCanvas, event)[0];
- ghostLine(point.x1, point.y1, terminalX, point.y1, true);
- rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 0);
- var terminalSideLength = terminalX - point.x1;
- var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
- var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
- var angle = degInRadians * 180 / Math.PI;
- console.log(angle);
- }
- else if(drawDir.Q == 2){
- terminalX = (point.x1 - getCursorPosition(tempCanvas, event)[0]) + point.x1;
- ghostLine(point.x1, point.y1, terminalX, point.y1, true);
- rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 0);
- terminalY = (getCursorPosition(tempCanvas, event)[1] - point.y1) + point.y1;
- ghostLine(point.x1, point.y1, point.x1, terminalY, true);
- rayArrow(point.x1, terminalY, 4, 0.5, t_ctx, 90);
- var terminalSideLength = terminalX - point.x1;
- var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
- var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
- var angle = degInRadians * 180 / Math.PI;
- console.log(180 - angle);
- }
- else if(drawDir.Q == 3){
- terminalX = (point.x1 - getCursorPosition(tempCanvas, event)[0]) + point.x1;
- ghostLine(point.x1, point.y1, terminalX, point.y1, true);
- rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 0);
- terminalY = point.y1 - (getCursorPosition(tempCanvas, event)[1] - point.y1);
- ghostLine(point.x1, point.y1, point.x1, terminalY, true);
- rayArrow(point.x1, terminalY, 4, 0.5, t_ctx, 90);
- terminalNegX = point.x1 - (point.x1 - getCursorPosition(tempCanvas, event)[0]);
- ghostLine(point.x1, point.y1, terminalNegX, point.y1, true);
- rayArrow(terminalNegX, point.y1, 4, 0.5, t_ctx, 180);
- var terminalSideLength = terminalX - point.x1;
- var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
- var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
- var angle = degInRadians * 180 / Math.PI;
- console.log(180 + angle);
- }
- else if(drawDir.Q == 4){
- terminalX = (point.x1 - getCursorPosition(tempCanvas, event)[0]) + point.x1;
- ghostLine(point.x1, point.y1, terminalX, point.y1, true);
- rayArrow(terminalX, point.y1, 4, 0.5, t_ctx, 180);
- terminalY = point.y1 - (getCursorPosition(tempCanvas, event)[1] - point.y1);
- ghostLine(point.x1, point.y1, point.x1, terminalY, true);
- rayArrow(point.x1, terminalY, 4, 0.5, t_ctx, 90);
- terminalNegX = point.x1 - (point.x1 - getCursorPosition(tempCanvas, event)[0]);
- ghostLine(point.x1, point.y1, terminalNegX, point.y1, true);
- rayArrow(terminalNegX, point.y1, 4, 0.5, t_ctx, 0);
- terminalNegY = point.y1 - (point.y1 - getCursorPosition(tempCanvas, event)[1]);
- ghostLine(point.x1, point.y1, point.x1, terminalNegY, true);
- rayArrow(point.x1, terminalNegY, 4, 0.5, t_ctx, 270);
- var terminalSideLength = terminalX - point.x1;
- var hypotenuseLength = Math.sqrt(Math.pow((prevX - currX), 2) + Math.pow((prevY - currY), 2));
- var degInRadians = Math.acos(terminalSideLength / hypotenuseLength);
- var angle = degInRadians * 180 / Math.PI;
- console.log(180 + angle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement