From f45f47b57234c81d194841c124b204bf32187edf Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Mon, 31 Oct 2022 09:58:03 -0300 Subject: [PATCH] Add lab 13 skeleton --- journal/_src/posts/2022-10-26-lab-13.md | 9 ++++++ labs/L13/animation.js | 39 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 journal/_src/posts/2022-10-26-lab-13.md create mode 100644 labs/L13/animation.js diff --git a/journal/_src/posts/2022-10-26-lab-13.md b/journal/_src/posts/2022-10-26-lab-13.md new file mode 100644 index 0000000..6825419 --- /dev/null +++ b/journal/_src/posts/2022-10-26-lab-13.md @@ -0,0 +1,9 @@ + Title: Lab Thirteen + Date: 2022-10-26T08:30:00 + Tags: cs2613, lab, javascript + +Sample description + + +## Sample Body +Sample Body \ No newline at end of file diff --git a/labs/L13/animation.js b/labs/L13/animation.js new file mode 100644 index 0000000..3c85b15 --- /dev/null +++ b/labs/L13/animation.js @@ -0,0 +1,39 @@ +// let str=""; +// for (let i=0; i<60; i++) { +// console.log('\033c'); +// str+= "*"; +// console.log(str); +// } + +//console.log("all done!"); + +// function loop(i,str) { +// if (i>0) { +// console.log("\033c"); +// console.log(str); +// setTimeout(function() { loop(i-1, str+"*"); }, 1000); +// } +// } + +// loop(20,"*"); + +// console.log("all done!"); + +function animate(iterations) { + let i=0; + let str="*"; + let timer = null; + function frame() { + + console.log('\033c'); + console.log(str); + if (i>=iterations) { + clearInterval(timer); + console.log("all done!"); + } + + } + timer=setInterval(frame,300); +} + +animate(20); \ No newline at end of file