Higher FPS! (#19)
This commit is contained in:
13
src/utils.js
13
src/utils.js
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user