-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,129 additions
and
257 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"extends": [ | ||
"development" | ||
], | ||
"hints": { | ||
"no-inline-styles": "off", | ||
"compat-api/css": [ | ||
"default", | ||
{ | ||
"ignore": [ | ||
"height: fit-content", | ||
"overflow-wrap: anywhere" | ||
] | ||
} | ||
], | ||
"detect-css-reflows/composite": "off", | ||
"detect-css-reflows/layout": "off", | ||
"detect-css-reflows/paint": "off", | ||
"axe/forms": [ | ||
"default", | ||
{ | ||
"select-name": "off", | ||
"label": "off" | ||
} | ||
], | ||
"axe/aria": [ | ||
"default", | ||
{ | ||
"aria-required-attr": "off", | ||
"aria-toggle-field-name": "off", | ||
"aria-allowed-attr": "off" | ||
} | ||
], | ||
"disown-opener": "off", | ||
"axe/name-role-value": [ | ||
"default", | ||
{ | ||
"link-name": "off" | ||
} | ||
] | ||
} | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// @ts-ignore | ||
/** @typedef {import("./engine.js")} */ | ||
|
||
"use strict"; | ||
|
||
class Animator extends Engine { | ||
/** | ||
* @param {HTMLCanvasElement} canvas | ||
* @param {Boolean} launch | ||
*/ | ||
constructor(canvas, launch = false) { | ||
super(launch); | ||
const instance = this; | ||
instance.#handler = () => { }; | ||
const context = (() => { | ||
const result = canvas.getContext(`2d`); | ||
if (!result) { | ||
throw new ReferenceError(`Element 'context' isn't defined.`); | ||
} | ||
return result; | ||
})(); | ||
function resize() { | ||
const { width, height } = canvas.getBoundingClientRect(); | ||
canvas.width = width; | ||
canvas.height = height; | ||
context.translate(width / 2, height / 2); | ||
instance.#handler(context); | ||
} | ||
resize(); | ||
window.addEventListener(`resize`, resize); | ||
super.renderer(() => { | ||
instance.#handler(context); | ||
}); | ||
} | ||
/** @type {(context: CanvasRenderingContext2D) => void} */ #handler; | ||
/** | ||
* @param {(context: CanvasRenderingContext2D) => void} handler | ||
*/ | ||
renderer(handler) { | ||
this.#handler = handler; | ||
} | ||
/** | ||
* @param {Number} period time in miliseconds | ||
* @returns multiplier - [0, 1] | ||
*/ | ||
impulse(period) { | ||
return this.time % period / period; | ||
} | ||
/** | ||
* @param {Number} period time in miliseconds | ||
* @returns multiplier - [-1, 1] | ||
*/ | ||
pulse(period) { | ||
return Math.sin(this.impulse(period) * 2 * Math.PI); | ||
} | ||
/** | ||
* @param {Number} period time in miliseconds | ||
* @returns multiplier - [0, 1] | ||
*/ | ||
bounce(period) { | ||
return Math.abs(this.pulse(period)); | ||
} | ||
} |
Oops, something went wrong.