made with requirebin
Created
May 29, 2014 20:23
-
-
Save nrw/c3e305718a2383633fa5 to your computer and use it in GitHub Desktop.
requirebin sketch
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
require('fs') // at the time of writing, requirebin needs a require. | |
var canvas = document.createElement("canvas") | |
var ctx = canvas.getContext('2d') | |
// setup canvas | |
document.body.style.margin = document.body.style.padding = 0 | |
document.body.appendChild(canvas) | |
requestAnimationFrame(tick) | |
function tick () { | |
resize() | |
requestAnimationFrame(tick) | |
} | |
function resize () { | |
// only resize canvas if necessary | |
if (canvas.width !== window.innerWidth) canvas.width = window.innerWidth; | |
if (canvas.height !== window.innerHeight) canvas.height = window.innerHeight; | |
// red background so we can see it | |
ctx.fillStyle = '#f00' | |
// left 10 pixel space so the canvas edge is visible | |
ctx.fillRect(0, 0, canvas.width-10, canvas.height-10) | |
} |
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
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"6dPUGs":[function(require,module,exports){},{}],fs:[function(require,module,exports){module.exports=require("6dPUGs")},{}]},{},[]);require("fs");var canvas=document.createElement("canvas");var ctx=canvas.getContext("2d");document.body.style.margin=document.body.style.padding=0;document.body.appendChild(canvas);requestAnimationFrame(tick);function tick(){resize();requestAnimationFrame(tick)}function resize(){if(canvas.width!==window.innerWidth)canvas.width=window.innerWidth;if(canvas.height!==window.innerHeight)canvas.height=window.innerHeight;ctx.fillStyle="#f00";ctx.fillRect(0,0,canvas.width-10,canvas.height-10)} |
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
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": {} | |
} |
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
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment