Skip to content

Instantly share code, notes, and snippets.

@aemkei
Forked from 140bytes/LICENSE.txt
Created October 5, 2011 17:06
Show Gist options
  • Save aemkei/1265021 to your computer and use it in GitHub Desktop.
Save aemkei/1265021 to your computer and use it in GitHub Desktop.
JS ASCII Logo - 140byt.es

JS ASCII Logo - 140byt.es

My second attempt to draw the JS Community logo in less than 140 bytes.

This time parsing binary bitmap data in pure JavaScript. See the example.

Update: The source is now included in the official logo.js repository.

Example output

    ████████████████████████
    ████████████████████████
    ████████████████████████
    ████████████████████████
    ████████████████████████
    ██████████  ████    ████
    ██████████  ██  ████████
    ██████████  ████    ████
    ██████████  ████████  ██
    ██████████  ██  ████  ██
    ██████    ██████    ████
    ████████████████████████

For more information

See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.

To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.

140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.

function f ( // all arguments are placeholder
a, // character to replace
b, // index
c // binary string
){
for (
b = 12; // read 12 lines
b--;
c = [c] + (
4095 ^ [ // combine with 2^12
// reversed bitmap array:
, // 111111111111
396, // 111001110011
82, // 111110101101
66, // 111110111101
76, // 111110110011
80, // 111110101111
76 // 111110110011
][ b ]
).toString(2) // convert decimals to binary presentation
+ 2 // add "2" to end of line
);
return " ■\n"[ // charater map 0 > space, 1 > block, 2 > new line
a // get "0", "1" or "2" from string
] || c.replace( // replace characters
/./g, f // read binary string
)
}
function f(a,b,c){for(b=12;b--;c=[c]+(4095^[,396,82,66,76,80,76][b]).toString(2)+2);return" ■\n"[a]||c.replace(/./g,f)}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "jsLogo",
"description": "Renders the JS community logo in ASCII art",
"keywords": [
"ascii",
"binary",
"js",
"logo"
]
}
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>JS ASCII Logo - 140Byt.es</title>
<style>
#logo {
font-family: "Courier New", monospace;
color: #F0DB4F;
background: #323330;
display: inline-block;
white-space: pre;
line-height: 33px;
font-size: 55px;
}
</style>
</head>
<body>
<div id="logo"></div>
<script>
var logo = function f(a,b,c){for(b=12;b--;c=[c]+(4095^[,396,82,66,76,80,76][b]).toString(2)+2);return" ■\n"[a]||c.replace(/./g,f)}
document.getElementById( "logo" ).innerHTML = logo()
</script>
</body>
@maettig
Copy link

maettig commented Dec 11, 2011

I tried to crunch the JS logo in 140 bytes SVG. I failed since my version depends on an external resource called "Arial".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment