Skip to content

Commit

Permalink
feat: add replay button
Browse files Browse the repository at this point in the history
  • Loading branch information
duong755 committed Dec 28, 2023
1 parent ae08c30 commit d579c65
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions heighway-dragon.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<body>
<div class="container">
<button type="button" id="replay">Replay</button>
<canvas id="heighway-drachen"></canvas>
</div>
<script src="helpers.js"></script>
Expand Down
9 changes: 6 additions & 3 deletions heighway-dragon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
function draw () {
/**
* @type {HTMLCanvasElement}
*/
Expand All @@ -10,12 +10,15 @@
const w = width,
h = width;
const ctx = canvas.getContext("2d");
ctx.lineWidth = 5;
ctx.lineWidth = 4;

for (let iteration = 0; iteration <= 20; iteration++) {
setTimeout(() => {
ctx.clearRect(0, 0, w, h);
drawHeighwayDrachen(ctx, [w / 5, h / 2], [(4 * w) / 5, h / 2], iteration);
}, iteration * 1000);
}
})();
}

draw();
document.getElementById("replay").addEventListener("click", draw);
1 change: 1 addition & 0 deletions koch-antisnowflake.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<body>
<div class="container">
<button type="button" id="replay">Replay</button>
<canvas id="koch-antisnowflake"></canvas>
</div>
<script src="helpers.js"></script>
Expand Down
7 changes: 5 additions & 2 deletions koch-antisnowflake.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
function draw () {
/**
* @type {HTMLCanvasElement}
*/
Expand Down Expand Up @@ -28,4 +28,7 @@
drawKochAntisnowflake(ctx, triangle, iteration);
}, iteration * 1000);
}
})();
}

draw();
document.getElementById("replay").addEventListener("click", draw);
1 change: 1 addition & 0 deletions koch-curve.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<body>
<div class="container">
<button type="button" id="replay">Replay</button>
<canvas id="koch-curve"></canvas>
</div>
<script src="helpers.js"></script>
Expand Down
10 changes: 6 additions & 4 deletions koch-curve.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
function draw () {
/**
* @type {HTMLCanvasElement}
*/
Expand All @@ -17,6 +17,8 @@
ctx.clearRect(0, 0, w, h);
drawKochCurve(ctx, [0, 2 * h /3], [w, 2 * h / 3], iteration);
}, iteration * 1000);
}

})();
}
}

draw();
document.getElementById("replay").addEventListener("click", draw);
1 change: 1 addition & 0 deletions koch-snowflake.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<body>
<div class="container">
<button type="button" id="replay">Replay</button>
<canvas id="koch-snowflake"></canvas>
</div>
<script src="helpers.js"></script>
Expand Down
6 changes: 4 additions & 2 deletions koch-snowflake.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
function draw () {
/**
* @type {HTMLCanvasElement}
*/
Expand Down Expand Up @@ -28,5 +28,7 @@
drawKochSnowflake(ctx, triangle, iteration);
}, iteration * 1000);
}
})();
}

draw();
document.getElementById("replay").addEventListener("click", draw);
1 change: 1 addition & 0 deletions minkowski-island.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<body>
<div class="container">
<button type="button" id="replay">Replay</button>
<canvas id="minkowski-insel"></canvas>
</div>
<script src="helpers.js"></script>
Expand Down
7 changes: 5 additions & 2 deletions minkowski-island.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
function draw () {
/**
* @type {HTMLCanvasElement}
*/
Expand All @@ -25,4 +25,7 @@
drawMinkowskiInsel(ctx, viereck, iteration);
}, iteration * 1000);
}
})();
}

draw();
document.getElementById("replay").addEventListener("click", draw);
1 change: 1 addition & 0 deletions minkowski-sausage.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<body>
<div class="container">
<button type="button" id="replay">Replay</button>
<canvas id="minkowski-wurst"></canvas>
</div>
<script src="helpers.js"></script>
Expand Down
7 changes: 5 additions & 2 deletions minkowski-sausage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function () {
function draw () {
/**
* @type {HTMLCanvasElement}
*/
Expand All @@ -18,4 +18,7 @@
drawMinkowskiWurst(ctx, [0, h / 2], [w, h / 2], step);
}, step * 1000);
}
})();
}

draw();
document.getElementById("replay").addEventListener("click", draw);

0 comments on commit d579c65

Please sign in to comment.