Skip to content
Snippets Groups Projects
Commit 7dd4709d authored by Shraddha Raghuram's avatar Shraddha Raghuram
Browse files

fix horiontal line function

parent 3d4fe30b
No related branches found
No related tags found
No related merge requests found
......@@ -138,48 +138,98 @@ function horizontalLine(x1, x2, y, ctx, canvas_h, typeID, lineID) {
if (typeID == 1) {
if (current_line >= y && canvas_h >= y){
if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
if (lines[lineID] < x2){
lines[lineID] += 10;
}
if (lines[lineID] < x2){
setTimeout("draw()", 120);
}
}
if (canvas_h < y && lines[lineID] > x1 && current_line == y){
if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
if (lines[lineID] > x1){
lines[lineID] -= 10;
}
if (lines[lineID] > x1){
setTimeout("draw()", 80);
}
if (canDraw(y - 150, y + 150)) ctx.lineTo(x2, y); // Ensure line ends at x2
// Remove or comment out these lines to prevent the branches from extending
// if (lines[lineID] < x2){
// lines[lineID] += 10;
// }
// if (lines[lineID] < x2){
// setTimeout("draw()", 120);
// }
}
// Remove or comment out these lines to avoid extending in reverse scroll
// if (canvas_h < y && lines[lineID] > x1 && current_line == y){
// if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
// if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
// if (lines[lineID] > x1){
// lines[lineID] -= 10;
// }
// if (lines[lineID] > x1){
// setTimeout("draw()", 80);
// }
// }
}
else if (typeID == 2) {
if (current_line >= y && canvas_h >= y){
if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
if (lines[lineID] > x2){
lines[lineID] -= 10;
}
if (lines[lineID] > x2){
setTimeout("draw()", 120);
}
}
if (canvas_h < y && lines[lineID] < x1 && current_line == y){
if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
if (lines[lineID] < x1){
lines[lineID] += 10;
}
if (lines[lineID] < x1){
setTimeout("draw()", 80);
}
if (canDraw(y - 150, y + 150)) ctx.lineTo(x2, y); // Ensure line ends at x2
// Remove or comment out these lines to prevent the branches from extending
// if (lines[lineID] > x2){
// lines[lineID] -= 10;
// }
// if (lines[lineID] > x2){
// setTimeout("draw()", 120);
// }
}
// Remove or comment out these lines to avoid extending in reverse scroll
// if (canvas_h < y && lines[lineID] < x1 && current_line == y){
// if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
// if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
// if (lines[lineID] < x1){
// lines[lineID] += 10;
// }
// if (lines[lineID] < x1){
// setTimeout("draw()", 80);
// }
// }
}
}
// function horizontalLine(x1, x2, y, ctx, canvas_h, typeID, lineID) {
// if (typeID == 1) {
// if (current_line >= y && canvas_h >= y){
// if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
// if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
// if (lines[lineID] < x2){
// lines[lineID] += 10;
// }
// if (lines[lineID] < x2){
// setTimeout("draw()", 120);
// }
// }
// if (canvas_h < y && lines[lineID] > x1 && current_line == y){
// if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
// if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
// if (lines[lineID] > x1){
// lines[lineID] -= 10;
// }
// if (lines[lineID] > x1){
// setTimeout("draw()", 80);
// }
// }
// }
// else if (typeID == 2) {
// if (current_line >= y && canvas_h >= y){
// if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
// if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
// if (lines[lineID] > x2){
// lines[lineID] -= 10;
// }
// if (lines[lineID] > x2){
// setTimeout("draw()", 120);
// }
// }
// if (canvas_h < y && lines[lineID] < x1 && current_line == y){
// if (canDraw(y - 150, y + 150)) ctx.moveTo(x1, y);
// if (canDraw(y - 150, y + 150) && x1 != lines[lineID]) ctx.lineTo(lines[lineID], y);
// if (lines[lineID] < x1){
// lines[lineID] += 10;
// }
// if (lines[lineID] < x1){
// setTimeout("draw()", 80);
// }
// }
// }
// }
function draw(){
/** @type {HTMLCanvasElement} */
let scrTop = document.documentElement.scrollTop;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment