Last active
August 29, 2015 14:06
-
-
Save moimikey/ed5fc4b9fee3facd7641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# create an insanely tiny placeholder gif | |
# output in base64 | |
# | |
# i'm still working the bytes... so this is | |
# a working proto but it needs to be further | |
# edited... | |
# | |
# as much as possible in accordance to GIF spec. | |
class Dick | |
createDummyGif: (width=10, height=10) -> | |
gif = '' | |
chars = [ | |
71, 73, 70, 56, 57, 97 # 6 bytes (header: GIF89a) | |
width, 0, height, 0 # 4 bytes (logical screen width, logical screen height) | |
44 # 1 byte (packed field of 8 bits) | |
# | |
# 1 = global color table flag (we want this on) | |
# 0 1 1 = color resolution | |
# null = sort flag (withheld) | |
# null = size of global color table (withheld) | |
# = | |
# 1011 00 | |
# | |
0 # 1 byte (bg color index) | |
255 # 1 byte (pixel aspect ratio) | |
0, 0, 0 # 3 bytes (global color table: black) | |
59 # 1 byte (trailer: ;) | |
] | |
for char in chars | |
gif += String.fromCharCode(char) | |
btoa gif | |
a = new Dick | |
console.log a.createDummyGif(10,10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment