Skip to content

Commit

Permalink
Improve efficiency of AA
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennard Schober committed May 8, 2024
1 parent 351917a commit ab80d3c
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions js/scripts3.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@ document.getElementById("sizeSlider").oninput = function () {

anchorFixed = false;

console.log(padding);

resetCanvas();
}

Expand All @@ -481,20 +479,12 @@ function rasterize() {
timeDisplay.textContent = "" + ((t1 - t0) / 100).toFixed(2) + "\u03BC" + "s";
break;
case "aa":
if (gridSize > 150) {
var t0 = performance.now();
var t0 = performance.now();
for (let i = 0; i < 100; i++) {
rasterizeAntiAliasedLine();
var t1 = performance.now();
timeDisplay.textContent = "" + ((t1 - t0)).toFixed(0) + "ms";
}
else {
var t0 = performance.now();
for (let i = 0; i < 10; i++) {
rasterizeAntiAliasedLine();
}
var t1 = performance.now();
timeDisplay.textContent = "" + ((t1 - t0) / 10).toFixed(1) + "ms";
}
var t1 = performance.now();
timeDisplay.textContent = "" + ((t1 - t0) / 100).toFixed(2) + "ms";
break;
case "midPoint":
var t0 = performance.now();
Expand Down Expand Up @@ -552,7 +542,6 @@ function rasterizeBresenham() {
}

function rasterizeAntiAliasedLine() {
resetCanvas();
const x0 = originPoint[1];
const y0 = originPoint[0];
const x1 = anchorPoint[1];
Expand All @@ -570,7 +559,6 @@ function rasterizeAntiAliasedLine() {
}
});
});
drawGrid();
}

function lineThroughPixel(x, y, x1, y1, x2, y2) {
Expand Down

0 comments on commit ab80d3c

Please sign in to comment.