Skip to content

Instantly share code, notes, and snippets.

@1j01
Last active June 8, 2018 03:09
Show Gist options
  • Save 1j01/5120aaa90789d1929d0c27a78075aa52 to your computer and use it in GitHub Desktop.
Save 1j01/5120aaa90789d1929d0c27a78075aa52 to your computer and use it in GitHub Desktop.
|[<-'*/]^[\*'->]| ):\<^/A]H[A\^>/:( |[<-'*/]^[\*'->]|
function generateSymmetricTextLine() {
const selfSymmetricChars = "*#^!+=-.':oO08|HAIX_WMVT";
const chars1 = ">>><<</\*^:_.-'|!~)()()][[{}{";
const chars2 = "<<<>>>\/*^:_.-'|!~()()([]]}{}";
const maxWidth = 10;
const maxNumChars = maxWidth - 2;
const numChars = maxNumChars - Math.floor(Math.random() * 5);
let string = selfSymmetricChars[~~(Math.random() * selfSymmetricChars.length)];
for (let i = 0; i < numChars; i += 1) {
let leftChar, rightChar;
if (Math.random() < 1 / 5) {
let randomIndex = Math.floor(Math.random() * selfSymmetricChars.length);
leftChar = selfSymmetricChars[randomIndex];
rightChar = selfSymmetricChars[randomIndex];
} else {
let randomIndex = Math.floor(Math.random() * chars1.length);
leftChar = chars1[randomIndex];
rightChar = chars2[randomIndex];
}
string = leftChar + string + rightChar;
}
return " ".repeat(maxWidth - numChars) + string;
}
var result = Array(100).fill().map(generateSymmetricTextLine).join("\n");
console.log(result);
var chars0,chars1,chars2,str,str2,rnd,numChrs,i,sp,spp,c;
chars0="*#^!+=-.':oO08|HAIX_WMVT";
chars1=">>><<</\*^:_.-'|!~)()()][[{}{";
chars2="<<<>>>\/*^:_.-'|!~()()([]]}{}";
chars1=chars1+chars1+chars1+chars1+chars0;
chars2=chars2+chars2+chars2+chars2+chars0;
str2="";
sp=0;
spp=sp;
for(i=0; i<100; i+=1){
str=string_char_at(chars0,random(string_length(chars0)));
numChrs=random(5)+3
repeat(numChrs){
rnd=random(string_length(chars1))
char1=string_char_at(chars1,rnd);
char2=string_char_at(chars2,rnd);
str=char1+str+char2
}
/*
sp=round((cos(i/10)+0.5)*5);
c="|";
if(spp<sp)c="\";
if(spp>sp)c="/";
str2+=string_repeat(" ",10+sp)+c+nl;
spp=sp;
*/
str2+=string_repeat(" ",10-numChrs+sp)+str+nl;
}
print(str2);
clipboard_set_text(str2);
var chars0,chars1,chars2,str,str2,rnd,numChrs,i,j,sp,spp,c;
chars0="*#^!+=-.':oO08|HAIX_WMVT";
chars1=">>><<</\*^:_.-'|!~)()()][[{}{";
chars2="<<<>>>\/*^:_.-'|!~()()([]]}{}";
chars1=chars1+chars1+chars1+chars1+chars0;
chars2=chars2+chars2+chars2+chars2+chars0;
str2="";
sp=0;
spp=sp;
for(i=0; i<100; i+=1){
str=chars0[~~(Math.random()*chars0.length)];
numChrs=~~(Math.random()*5)+3
for(j=0; j<numChrs; j+=1){
rnd=~~(Math.random()*chars1.length);
char1=chars1[rnd];
char2=chars2[rnd];
str=char1+str+char2;
}
str2+=" ".repeat(10-numChrs+sp)+str+"\n";
}
console.log(str2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment