Skip to content

Commit

Permalink
2.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
eccs0103 committed May 11, 2023
1 parent 40c12d9 commit afefdd3
Show file tree
Hide file tree
Showing 21 changed files with 1,129 additions and 257 deletions.
42 changes: 42 additions & 0 deletions .hintrc
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"
}
]
}
}
15 changes: 10 additions & 5 deletions pages/sandbox.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="system">

<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type: text/html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sandbox - Elements</title>
<link rel="shortcut icon" href="../resources/grid.png">
<title>Elements - Sandbox</title>
<link rel="shortcut icon" href="../resources/grid.png" media="(prefers-color-scheme: light)">
<link rel="shortcut icon" href="../resources/grid (inverted).png" media="(prefers-color-scheme: dark)">
<link rel="stylesheet" href="../styles/style.css">
<link id="theme" rel="stylesheet">
<script src="../scripts/modules.js" defer></script>
<link rel="stylesheet" href="../styles/themes/material.css">
<script src="../scripts/modules/archive.js" defer></script>
<script src="../scripts/modules/application.js" defer></script>
<script src="../scripts/modules/color.js" defer></script>
<script src="../scripts/modules/random.js" defer></script>
<script src="../scripts/structure.js" defer></script>
<script src="../scripts/sandbox.js" defer></script>
</head>
Expand Down
15 changes: 10 additions & 5 deletions pages/settings.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-theme="system">

<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type: text/html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Settings - Elements</title>
<link rel="shortcut icon" href="../resources/settings.png">
<title>Elements - Settings</title>
<link rel="shortcut icon" href="../resources/settings.png" media="(prefers-color-scheme: light)">
<link rel="shortcut icon" href="../resources/settings (inverted).png" media="(prefers-color-scheme: dark)">
<link rel="stylesheet" href="../styles/style.css">
<link id="theme" rel="stylesheet">
<script src="../scripts/modules.js" defer></script>
<link rel="stylesheet" href="../styles/themes/material.css">
<script src="../scripts/modules/archive.js" defer></script>
<script src="../scripts/modules/application.js" defer></script>
<script src="../scripts/modules/color.js" defer></script>
<script src="../scripts/modules/random.js" defer></script>
<script src="../scripts/structure.js" defer></script>
<script src="../scripts/settings.js" defer></script>
</head>
Expand Down
Binary file added resources/grid (inverted).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/home.png
Binary file not shown.
Binary file added resources/info (inverted).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/settings (inverted).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 13 additions & 8 deletions scripts/elements.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// @ts-ignore
/** @typedef {import("./sandbox")} */

"use strict";

//#region Dirt
class Dirt extends Elemental {
static title = `Dirt`;
static color = new Color(150, 100, 80);
static color = Color.viaRGB(150, 100, 80);
constructor() {
super();
this._title = Dirt.title;
Expand All @@ -13,7 +18,7 @@ board.cases.set(Dirt, 90);
//#region Grass
class Grass extends Elemental {
static title = `Grass`;
static color = new Color(0, 128, 0);
static color = Color.viaRGB(0, 128, 0);
static durationGrow = 10;
constructor() {
super();
Expand Down Expand Up @@ -47,7 +52,7 @@ board.cases.set(Grass, 4);
//#region Fire
class Fire extends Elemental {
static title = `Fire`;
static color = new Color(255, 150, 0);
static color = Color.viaRGB(255, 150, 0);
static durationBurn = 4;
static durationFade = 16;
constructor() {
Expand Down Expand Up @@ -83,7 +88,7 @@ board.cases.set(Fire, 2);
//#region Water
class Water extends Elemental {
static title = `Water`;
static color = new Color(0, 50, 255);
static color = Color.viaRGB(0, 50, 255);
static durationFlow = 8;
static durationEvaporate = 8;
constructor() {
Expand Down Expand Up @@ -136,7 +141,7 @@ board.cases.set(Water, 2);
//#region Lava
class Lava extends Elemental {
static title = `Lava`;
static color = new Color(255, 0, 0);
static color = Color.viaRGB(255, 0, 0);
static maxDensity = 3;
static durationFlow = 15;
static durationBurn = 8;
Expand All @@ -149,7 +154,7 @@ class Lava extends Elemental {
super();
this._title = Lava.title;
this.#density = density;
this._color = new Color(
this._color = Color.viaRGB(
((Lava.color.red - Fire.color.red) * this.#density / Lava.maxDensity) + Fire.color.red,
((Lava.color.green - Fire.color.green) * this.#density / Lava.maxDensity) + Fire.color.green,
((Lava.color.blue - Fire.color.blue) * this.#density / Lava.maxDensity) + Fire.color.blue,
Expand Down Expand Up @@ -222,7 +227,7 @@ board.cases.set(Lava, 1);
//#region Ice
class Ice extends Elemental {
static title = `Ice`;
static color = new Color(0, 200, 255);
static color = Color.viaRGB(0, 200, 255);
static maxDensity = 3;
static durationFlow = 12;
static durationMelt = 4;
Expand All @@ -235,7 +240,7 @@ class Ice extends Elemental {
super();
this._title = Ice.title;
this.#density = density;
this._color = new Color(
this._color = Color.viaRGB(
((Ice.color.red - Water.color.red) * this.#density / Ice.maxDensity) + Water.color.red,
((Ice.color.green - Water.color.green) * this.#density / Ice.maxDensity) + Water.color.green,
((Ice.color.blue - Water.color.blue) * this.#density / Ice.maxDensity) + Water.color.blue,
Expand Down
93 changes: 0 additions & 93 deletions scripts/modules.js

This file was deleted.

63 changes: 63 additions & 0 deletions scripts/modules/animator.js
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));
}
}
Loading

0 comments on commit afefdd3

Please sign in to comment.