Skip to content

Instantly share code, notes, and snippets.

@epidemian
Created March 31, 2014 03:54
Show Gist options
  • Save epidemian/9884954 to your computer and use it in GitHub Desktop.
Save epidemian/9884954 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<body>
<script src="//cdnjs.cloudflare.com/ajax/libs/coffee-script/1.7.1/coffee-script.min.js"></script>
<script src="owl.coffee" type="text/coffeescript"></script>
canvas = document.createElement 'canvas'
canvas.style.backgroundColor = '#240202'
canvas.style.transform = 'scale(0.5) translate(-480px,-570px)'
W = canvas.width = 960
H = canvas.height = 1140
D = 50
R = D / 2
ctx = canvas.getContext '2d'
imageData = ctx.getImageData 0, 0, W, H
data = imageData.data
owl = '''
\ * * * * * * * * *
\ * * * *
\ * * * * *
\ * * * *
\ * * * *
\ * * * *
\ * * * * *
\ * * *
\ * * * * * * * *
\ * * * *
\ * * * * * *
\ * * * *
\ * * * * *
\ * * * *
\ * * * * *
\ * * * *
\ * * * * *
\ * * *
\ * * * *
\ * * * * * * *
\ *
'''.split '\n'
insideDot = (x, y) ->
w = 0
for du in [-1..1] then for dv in [-1..1]
u = x // D + du
v = y // D + dv
continue unless owl[v]?[u] is '*'
dx = x - (u * D + R)
dy = y - (v * D + R)
d = dx * dx + dy * dy
w += 1 / (d * d)
return yes if w > 0.0000008
no
for y in [0...H] then for x in [0...W] when insideDot x, y
i = (y * W + x) * 4
data[i] = data[i+1] = data[i+3] = 255
data[i+2] = 214
ctx.putImageData imageData, 0, 0
document.body.appendChild canvas
@epidemian
Copy link
Author

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