Skip to content

Instantly share code, notes, and snippets.

@Cycymomo
Last active August 29, 2015 13:56
Show Gist options
  • Save Cycymomo/8931274 to your computer and use it in GitHub Desktop.
Save Cycymomo/8931274 to your computer and use it in GitHub Desktop.
ASCII_art_HelloWorld.js
// see : http://codegolf.stackexchange.com/questions/20209/ascii-art-hello-world/20211#20211
// That works in Firefox 27 Scratchpad.
// init : 178
c=document.createElement("canvas").getContext("2d");c.fillText("Hello-World!",0,7);d=c.getImageData(1,0,56,7).data;s="";for(i=3;i<1568;i+=4){s+=d[i]?"#":" ";s+=(i+1)%224?"":"\n"}
// golfed : 174
c=document.createElement("canvas").getContext("2d");c.fillText("Hello-World!",s="",7);d=c.getImageData(1,0,56,7).data;for(i=3;i<1568;i+=4)s+=d[i]?"#":" ",s+=(i+1)%224?"":"\n"
// see : https://twitter.com/aemkei/status/433204820632412160
// by @aemkei
r="";for(i in b=[0xa0a028045,0xeeae2bb5d,0xacaabaa54,0xaeae2ba5d])r+="\n"+b[i].toString(2).replace(/0/g," ").replace(/1/g,'#')
// by p01 [mirror]
r="";for(i=4;x=[0xaeae2ba5d,0xacaabaa54,0xeeae2bb5d,0xa0a028045][--i];)for(r+="\n",j=36;j--;)r+=" #"[x.toString(2)[j]]
// golfed
for(r=j=i="";x=[0xa0a028045,0xeeae2bb5d,0xacaabaa54,0xaeae2ba5d][i++];j=0)for(r+="\n";j<36;)r+=" #"[x.toString(2)[j++]]
// or ...
for(r=j="",i=4;i--;j=0)for(r+="\n";j<36;)r+=" #"[[46890400349,46349920852,64070269789,43117609029][i].toString(2)[j++]]
// or ...
for(i=s="";l=[43117609029,64070269789,46349920852,46890400349][i++];)for(j=0,s+="\n";c=l.toString(2)[j++];)s+=" #"[c]
(function(r,j,i){
for(r=j="",i=5;i--;j=0)for(r+="\n";j<34;r+=" #"[[11722600087,11587349141,16017567447,a=10779402257,a][i].toString(2)[j++]]);return r
}())
/*
"
# # # # # # # #
# # # # # # # #
### ### # # ### # # ### ## # ###
# # ## # # # # ### # # # # # #
# # ### # # ### # # ### # # ### "
*/
for(s=i="";i++<5;s+="#\n")for(j=0;x="949077509090757000939075707409075"[j++];)console.log('x : ' + x + ' / +x+i : ' + (+x+i) + ' / i*x : ' + (i*x) + ' / : 3*x+i : ' + (3*x+i))/*s+=" #"[+(+x+i>9||i*x==12||3*x+i==18)]*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment