From e1a03dc8ee61f9012997338238ced66da34824c4 Mon Sep 17 00:00:00 2001 From: Konstantin Timoshenko Date: Sun, 9 Jan 2022 18:18:43 +0300 Subject: [PATCH 1/2] Animation suport for american --- lib/custom/american.js | 73 +++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/lib/custom/american.js b/lib/custom/american.js index 5b0dc44..8b64338 100644 --- a/lib/custom/american.js +++ b/lib/custom/american.js @@ -1,31 +1,54 @@ +let t = 0; module.exports = function americanFlag () { console.log('LIBERTY LIBERTY LIBERTY'.yellow); console.log('LIBERTY LIBERTY LIBERTY'.america); console.log('LIBERTY LIBERTY LIBERTY'.yellow); - let flag = "\ - \ - !\ - H|H|H|H|H H__________________________________\ - H|§|§|§|H H|* * * * * *|---------------------|\ - H|§|∞|§|H H| * * * * * |---------------------|\ - H|§|§|§|H H|* * * * * *|---------------------|\ - H|H|H|H|H H| * * * * * |---------------------|\ - H|H|H|H|H H|---------------------------------|\ - =============== H|---------------------------------|\ - /| _ _ |\ H|---------------------------------|\ - (| O O |) H|---------------------------------|\ - /| U |\ H-----------------------------------\ - | \=/ | H\ - \_..._/ H\ - _|\I/|_ H\ - _______/\| H |/\_______ H\ - / \ \ / / \ H\ - | \ | | / | H\ - | ||o|| | H\ - | | ||o|| | | H\ - | | ||o|| | | H Carl Pilcher\ - "; + t ++; + let flag = + ` + + ! + H|H|H|H|H H__________________________________ + H|§|§|§|H H|* * * * * *|---------------------| + H|§|∞|§|H H| * * * * * |---------------------| + H|§|§|§|H H|* * * * * *|---------------------| + H|H|H|H|H H| * * * * * |---------------------| + H|H|H|H|H H|---------------------------------| + =============== H|---------------------------------| + /| _ _ |\\ H|---------------------------------| + (| O O |) H|---------------------------------| + /| U |\\ H----------------------------------- + | \\=/ | H + \\_..._/ H + _|\\I/|_ H + _______/\\| H |/\\_______ H + / \\ \\ / / \\ H + | \\ | | / | H + | ||o|| | H + | | ||o|| | | H + | | ||o|| | | H + `.split('\n') + .map((e) => e.padEnd(67)) + .map((e, il, a) => { + if (il > 14) { + return e; + } - console.log(flag); + let line = e.split(''); + + for(let i = 36; i < e.length; i ++) { + let o = Math.round(Math.sin(t + 2 * 3.14 * (i - 36) / 36) * 2); + + o += il; + + if (o >= a.length) o -= a.length; + if (o < 0) o += a.length; -} \ No newline at end of file + line[i] = a[o][i]; + } + + return line.join(''); + }).join('\n'); + + console.log(flag); +} From cb2c67c1111cdab0cdb6f73c774efdbcd1710c34 Mon Sep 17 00:00:00 2001 From: Konstantin Timoshenko Date: Sun, 9 Jan 2022 18:43:40 +0300 Subject: [PATCH 2/2] Fix: change o to y to increasing readabling --- lib/custom/american.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/custom/american.js b/lib/custom/american.js index 8b64338..5320402 100644 --- a/lib/custom/american.js +++ b/lib/custom/american.js @@ -37,14 +37,14 @@ module.exports = function americanFlag () { let line = e.split(''); for(let i = 36; i < e.length; i ++) { - let o = Math.round(Math.sin(t + 2 * 3.14 * (i - 36) / 36) * 2); + let y = Math.round(Math.sin(t + 2 * 3.14 * (i - 36) / (e.length - 36)) * 2); - o += il; + y += il; - if (o >= a.length) o -= a.length; - if (o < 0) o += a.length; + if (y >= a.length) y -= a.length; + if (y < 0) y += a.length; - line[i] = a[o][i]; + line[i] = a[y][i]; } return line.join('');