add zero-width space

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2023-04-09 09:20:06 -05:00
parent 0d7c7b6647
commit 2745467dbb

View File

@ -48,7 +48,7 @@ module.exports = {
//await interaction.reply('Error: String is too big. Resultant output would be too big to send to Discord. (the output length was ' + (output.length + testLength.length) + " characters.)"); //await interaction.reply('Error: String is too big. Resultant output would be too big to send to Discord. (the output length was ' + (output.length + testLength.length) + " characters.)");
let replyString = "output length was " + (output.length) + " characters."; let replyString = "output length was " + (output.length) + " characters.";
let filePath = writeFile(output); let filePath = writeFile(output);
await interaction.reply({content:replyString, files: [filePath] }); await interaction.reply({ content: replyString, files: [filePath] });
fs.unlinkSync(filePath); // Delete file once we're done with it fs.unlinkSync(filePath); // Delete file once we're done with it
} else { } else {
await interaction.reply(codeBlock("", output) + testLength); await interaction.reply(codeBlock("", output) + testLength);
@ -60,7 +60,7 @@ module.exports = {
function writeFile(content) { function writeFile(content) {
//console.log(content); //console.log(content);
console.log("Attempting to write string to file..."); console.log("Attempting to write string to file...");
let filename = Date.now()+'.txt'; let filename = Date.now() + '.txt';
console.log(filename); console.log(filename);
var filePath = path.join(__dirname, '..', filename); var filePath = path.join(__dirname, '..', filename);
console.log(filePath); console.log(filePath);
@ -69,7 +69,7 @@ function writeFile(content) {
console.error(err); console.error(err);
} }
}); });
return filePath; return filePath;
} }
function design1(input) { function design1(input) {
@ -179,24 +179,24 @@ function design4(input) {
for (i = 0; i <= 2 * radius; i++) { for (i = 0; i <= 2 * radius; i++) {
lineHasInput = false; lineHasInput = false;
if (Math.trunc(i) != mid) { if (Math.trunc(i) != mid) {
// for vertical movement // for vertical movement
for (j = 0; j <= 2 * radius; j++) { for (j = 0; j <= 2 * radius; j++) {
dist = Math.sqrt( dist = Math.sqrt(
((i - radius) * (i - radius) * 4) + // (* 4) accounts for the offset between lines ((i - radius) * (i - radius) * 4) + // (* 4) accounts for the offset between lines
(j - radius) * (j - radius) (j - radius) * (j - radius)
); );
//console.log(i, j, radius, dist); //console.log(i, j, radius, dist);
// dist should be in the range (radius - 0.5) // dist should be in the range (radius - 0.5)
// and (radius + 0.5) to print stars(*) // and (radius + 0.5) to print stars(*)
if (dist > radius - 1 && dist < radius + 1) { //&& dist > radius - 1 if (dist > radius - 1 && dist < radius + 1) { //&& dist > radius - 1
lineHasInput = true; lineHasInput = true;
outputLine += "​·"; //zero-width space outputLine += "​·"; //zero-width space
} else { } else {
outputLine += " "; outputLine += " ";
}
} }
}
} else { } else {
lineHasInput = true; lineHasInput = true;
outputLine += "​·" + space + input + space + spaceOffset + "·"; //zero-width space outputLine += "​·" + space + input + space + spaceOffset + "·"; //zero-width space
@ -214,11 +214,12 @@ var charIterateState;
function charIterate(input) { function charIterate(input) {
if (charIterateState == undefined) { if (charIterateState == undefined) {
charIterateState = 0; charIterateState = 0;
}
if (charIterateState < (input.length - 1)) {
charIterateState++;
} else { } else {
charIterateState = 0; if (charIterateState < (input.length - 1)) {
charIterateState++;
} else {
charIterateState = 0;
}
} }
console.log(charIterateState, input.charAt(charIterateState)); console.log(charIterateState, input.charAt(charIterateState));
return charIterateState; return charIterateState;
@ -248,24 +249,24 @@ function design5(input) {
for (i = 0; i <= 2 * radius; i++) { for (i = 0; i <= 2 * radius; i++) {
lineHasInput = false; lineHasInput = false;
if (Math.trunc(i) != mid) { if (Math.trunc(i) != mid) {
// for vertical movement // for vertical movement
for (j = 0; j <= 2 * radius; j++) { for (j = 0; j <= 2 * radius; j++) {
dist = Math.sqrt( dist = Math.sqrt(
((i - radius) * (i - radius) * 4) + // (* 4) accounts for the offset between lines ((i - radius) * (i - radius) * 4) + // (* 4) accounts for the offset between lines
(j - radius) * (j - radius) (j - radius) * (j - radius)
); );
//console.log(i, j, radius, dist); //console.log(i, j, radius, dist);
// dist should be in the range (radius - 0.5) // dist should be in the range (radius - 0.5)
// and (radius + 0.5) to print stars(*) // and (radius + 0.5) to print stars(*)
if (dist > radius - 1 && dist < radius + 1) { //&& dist > radius - 1 if (dist > radius - 1 && dist < radius + 1) { //&& dist > radius - 1
lineHasInput = true; lineHasInput = true;
outputLine += ""+ input.charAt(charIterate(input)); //zero-width space outputLine += "" + input.charAt(charIterate(input)); //zero-width space
} else { } else {
outputLine += " "; outputLine += " ";
}
} }
}
} else { } else {
lineHasInput = true; lineHasInput = true;
outputLine += input.charAt(charIterate(input)) + space + input + space + spaceOffset + input.charAt(charIterate(input)); outputLine += input.charAt(charIterate(input)) + space + input + space + spaceOffset + input.charAt(charIterate(input));