Skip to content

Commit 394d4f7

Browse files
committed
Initial commit.
0 parents  commit 394d4f7

File tree

6 files changed

+763
-0
lines changed

6 files changed

+763
-0
lines changed

Diff for: README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Pixels
2+
3+
This is the frontend code and image processing script for xkcd's ["Pixels"](http://xkcd.com/1416/).
4+
5+
[![Scroll to zoom.](http://imgs.xkcd.com/comics/pixels.png)](http://xkcd.com/1416/)

Diff for: demo.html

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<div id="comic">
3+
<script src="zoom.js"></script>
4+
<script>
5+
setTimeout(function() {
6+
turtles = new TurtlesDown(document.getElementById('comic'))
7+
turtles.start()
8+
}, 0)
9+
</script>
10+
</div>

Diff for: frame-demo.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!doctype html>
2+
<div id="comic">
3+
<iframe frameborder="0" scrolling="0" style="display: block; margin: 0 auto; border: none; overflow: hidden" width="600" height="600" src="frame.html"></iframe>
4+
</div>

Diff for: frame.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<style>
5+
html, body { margin: 0; overflow: hidden }
6+
</style>
7+
</head>
8+
<body>
9+
<div id="comic">
10+
<img src="http://imgs.xkcd.com/comics/pixels.png" title="It&#39;s turtles all the way down." alt="Pixels" />
11+
</div>
12+
<script src="zoom.js"></script>
13+
<script>
14+
turtles = new TurtlesDown(document.getElementById('comic'))
15+
turtles.start()
16+
</script>
17+
</body>
18+
</html>

Diff for: scale.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# pixels image scaler / spriter
2+
# by chromakode and davean
3+
4+
import sys
5+
import os
6+
import os.path
7+
import math
8+
from os import listdir
9+
10+
paths = ["600px/black", "600px/white"]
11+
12+
for color in ["black", "white"]:
13+
p = os.path.join("600px", color)
14+
imgs = [(f, os.path.splitext(os.path.basename(f))) for f in [os.path.join(p, wf) for wf in listdir(p)] if os.path.isfile(f)]
15+
16+
step = 1.5
17+
18+
for (target, (fname, ext)) in imgs:
19+
outputs = []
20+
21+
size = 600
22+
while size >= 1:
23+
scaled_name = "scaled/{fname}-{size}{ext}".format(
24+
fname=fname,
25+
size=size,
26+
ext=ext,
27+
)
28+
os.system("convert {target} -resize {size}x{size} -extent 600x600 {scaled_name}".format(
29+
target=target,
30+
size=size,
31+
scaled_name=scaled_name,
32+
))
33+
outputs.append(scaled_name)
34+
size = int(step ** (math.ceil(math.log(size, step)) - 1))
35+
36+
os.system("convert {outputs} +append scaled/{fname}-tiled{ext}".format(
37+
outputs=" ".join(outputs),
38+
fname=fname,
39+
ext=ext,
40+
))
41+
42+
for of in outputs:
43+
os.remove(of)

0 commit comments

Comments
 (0)