Skip to content

Instantly share code, notes, and snippets.

View dg1234uk's full-sized avatar
👨‍💻
...typing

Daniel Granger dg1234uk

👨‍💻
...typing
View GitHub Profile
@dg1234uk
dg1234uk / rAF.js
Last active August 29, 2015 14:04 — forked from paulirish/rAF.js
HTML: requestAnimationFrame polyfill
// 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;
@dg1234uk
dg1234uk / First-Pen.markdown
Created July 27, 2014 20:14
A Pen by Daniel Granger.
@dg1234uk
dg1234uk / CSS: Clear Fix.css
Last active April 3, 2016 12:01
CSS: Clear Fix
/* 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 */
@dg1234uk
dg1234uk / createHighDPICanvas.ts
Last active July 2, 2023 10:39
TypeScript function that creates a High DPI Canvas.
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