Higher FPS! (#19)

This commit is contained in:
gavin
2018-10-05 20:22:11 -04:00
committed by Gitea
parent 0e2b7ea69d
commit 52017e8e30
7 changed files with 160 additions and 49 deletions

View File

@@ -9,6 +9,9 @@ export const sqrt2 = Math.sqrt(2);
// (2*S gives long width)
export const sqrt3 = Math.sqrt(3);
// leg factor of isoscelese right triangle with unit hypotenuse
export const invSqrt2 = 1 / sqrt2
export function clone(obj) {
return JSON.parse(JSON.stringify(obj));
}
@@ -141,3 +144,13 @@ export function extend (obj, ...sources) {
return extended;
}
export function quickCanvas (draw, height, width = height) {
const canvas = document.createElement('canvas');
canvas.height = height;
canvas.width = width;
draw(canvas.getContext('2d'), canvas.height, canvas.width);
return canvas;
}