From 648bf44864f8abb391f6002673ffa0bdc6a77ba1 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Sat, 8 Apr 2023 19:04:09 -0500 Subject: [PATCH 1/3] Make circle more circular --- commands/drawDesign.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/drawDesign.cjs b/commands/drawDesign.cjs index 0689804..1685d48 100644 --- a/commands/drawDesign.cjs +++ b/commands/drawDesign.cjs @@ -174,8 +174,8 @@ function design4(input) { for (let j = 0; j <= 2 * radius; j++) { dist = Math.sqrt( - (i - radius / 2) * (i - radius / 2) + - (j - radius) * (j - radius) + (i - radius) * (i - radius) + + (j - (radius / 2)) * (j - (radius / 2)) ); // dist should be in the range (radius - 0.5) From 79064f4b3a8cb24f1e527f9f622f9a75d3b83233 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Sat, 8 Apr 2023 22:25:20 -0500 Subject: [PATCH 2/3] Make circle more circular --- commands/drawDesign.cjs | 46 +++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/commands/drawDesign.cjs b/commands/drawDesign.cjs index 1685d48..78ed44f 100644 --- a/commands/drawDesign.cjs +++ b/commands/drawDesign.cjs @@ -153,14 +153,15 @@ function design3(input) { function design4(input) { let outputString = ""; - let radius = input.length +1; + let outputLine = ""; + let radius = (input.length + 1); let mid = radius; if (mid % 2 == 1) { var spaceOffset = " "; } else { var spaceOffset = ""; } - + console.log(radius, mid); // dist represents distance to the center let dist = parseFloat(0); let space = "" @@ -168,33 +169,42 @@ function design4(input) { space += " "; } // for horizontal movement - for (let i = 0; i <= 2 * radius; i++) { - if (i != mid) { + var i; + var j; + let lineHasInput = false; + for (i = 0; i <= 2 * radius; i++) { + lineHasInput = false; + if (Math.trunc(i) != mid) { // for vertical movement - for (let j = 0; j <= 2 * radius; j++) { - + for (j = 0; j <= 2 * radius; j++) { dist = Math.sqrt( - (i - radius) * (i - radius) + - (j - (radius / 2)) * (j - (radius / 2)) + ((i - radius) * (i - radius) * 4) + + (j - radius) * (j - radius) ); - + //console.log(i, j, radius, dist); // dist should be in the range (radius - 0.5) // and (radius + 0.5) to print stars(*) - - if (dist > radius - 0.5 && dist < radius + 0.5) { - outputString += "*"; + + if (dist > radius - 1 && dist < radius + 1) { //&& dist > radius - 1 + lineHasInput = true; + outputLine += "·"; } else { - outputString += " "; + outputLine += " "; } - } } else { - outputString += "*" + space + input + space + spaceOffset + "*"; + lineHasInput = true; + outputLine += "·" + space + input + space + spaceOffset + "·"; } - - outputString += "\n"; + //console.log(i, j, outputLine); + if (lineHasInput) { + outputString += outputLine + "\n"; + } + outputLine = ""; } return outputString; -} \ No newline at end of file +} +console.log(design4("super long test string super long test string")); +//"super long test string super long test string" \ No newline at end of file From 797287acbf0296d0a959f0cdb0a1e24abbf8584a Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Sat, 8 Apr 2023 22:25:39 -0500 Subject: [PATCH 3/3] Make circle more circular --- commands/drawDesign.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/drawDesign.cjs b/commands/drawDesign.cjs index 78ed44f..b6281ea 100644 --- a/commands/drawDesign.cjs +++ b/commands/drawDesign.cjs @@ -206,5 +206,5 @@ function design4(input) { } return outputString; } -console.log(design4("super long test string super long test string")); +//console.log(design4("super long test string super long test string")); //"super long test string super long test string" \ No newline at end of file