Skip to content

Instantly share code, notes, and snippets.

@autotelicum
Created August 17, 2011 16:49
Show Gist options
  • Save autotelicum/1151993 to your computer and use it in GitHub Desktop.
Save autotelicum/1151993 to your computer and use it in GitHub Desktop.
CoffeeKup HTML5 canvas template
# Template for CoffeeKup HTML5 document with canvas
kup = require 'coffeekup'
webpage = kup.render ->
doctype 5
html ->
head ->
meta charset: 'utf-8'
title 'WEBPAGE'
style '''
body {color: #F7C762; background-color: #202020}
'''
coffeescript ->
window.onload = ->
$ = (element) -> document.getElementById element
@canvas = $ 'canvas'
@context = canvas.getContext '2d'
unless @context?
alert 'No canvas in this browser. Please upgrade.'
return
# ...
return
body ->
div id: 'container', ->
canvas id: 'canvas', width: 340, height: 210 # Golden ratio
# ...
, format:on # Comment out to get unformatted HTML
# To generate HTML run command `coffee WEBPAGE.coffee`
(require 'fs').writeFileSync './WEBPAGE.html', webpage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment