Let's increase the thickness of those intersected lines so we can distinguish them in the Canvas
Open the
untangle.drawing.js
file in the text editor.We have the
thinLineThickness
variable as the default line thickness. We add the following code to define a thickness for bold lines:untangleGame.boldLineThickness = 5;
Open the
untangle.data.js
file. We create a function to check whether the given two lines intersect. Add the following functions to the end of the JavaScript file:untangleGame.isIntersect = function(line1, line2) { // convert line1 to general form of line: Ax+By = C var a1 = line1.endPoint.y - line1.startPoint.y; var b1 = line1. startPoint.x - line1.endPoint.x; var c1 = a1 * line1.startPoint.x + b1 * line1.startPoint.y; // convert line2 to general form of line: Ax+By = C var a2 = line2.endPoint.y - line2.startPoint.y; var b2 = line2. startPoint.x - line2.endPoint.x; var c2 = a2 * line2.startPoint.x + b2...