My first pen, just a quick html 5 button which when clicked has its CSS background colour changed.
A Pen by Daniel Granger on CodePen.
function createHighDPICanvas(width: number, height: number, parentElement = document.body) { | |
// Validate inputs | |
if (typeof width !== 'number' || typeof height !== 'number') { | |
throw new Error("Width and height must be numbers"); | |
} | |
// Create a new HTML canvas element | |
const canvas = document.createElement("canvas"); | |
// Set the width and height of the canvas in CSS pixels |
/* http://css-tricks.com/snippets/css/clear-fix/ */ | |
.group:after { | |
visibility: hidden; | |
display: block; | |
content: ""; | |
clear: both; | |
height: 0; | |
} | |
* html .group { zoom: 1; } /* IE6 */ | |
*:first-child+html .group { zoom: 1; } /* IE7 */ |
// Forked from Paul Irish | |
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
// MIT license | |
(function() { | |
var lastTime = 0; |
My first pen, just a quick html 5 button which when clicked has its CSS background colour changed.
A Pen by Daniel Granger on CodePen.