5 Commits
v1.3.0 ... main

Author SHA1 Message Date
35ef8877ab Fix output data structure
This naming is very bad and it confused me
oops
2025-05-23 11:16:40 -07:00
f81fa98851 Disable BG animation
I've made the tough decision to disable the BG animation by default.
It's just to heavy on performance and is somewhat distracting for some
people. I'm planning on making a toggle on it, but I'm not sure that
will be done by the next release.
2025-05-16 19:40:36 -07:00
d23558cbfd I accidentally committed the release archive
I made a lot of mistakes with this release, what's next?
2025-05-09 20:26:58 -07:00
4bffe03f04 Bump version 2025-05-09 10:48:51 -07:00
98ec534d2e Light theme nav modal bugfix 2025-05-09 10:47:37 -07:00
6 changed files with 45 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{
"name": "colormatic-website",
"version": "1.2.1",
"version": "1.3.1",
"type": "module",
"scripts": {
"dev": "vite dev",

View File

@ -7,15 +7,22 @@
let { darkTheme = $bindable() } = $props();
let timeScale = 1;
let animated = false;
$effect(() => {
darkTheme;
for (let i = 0; i < gradients.length; i++) {
// This re-renders each gradient so their new color will be correct
let gradient = gradients[i];
gradient.color = getRandomColor();
gradient.prepareBuffer();
}
if (!animated && ctx) {
// Don't try to render if ctx hasn't initialized yet
render();
}
});
let particleImages: { [key: string]: HTMLImageElement } = {};
@ -58,8 +65,13 @@
return {};
});
Promise.all(Object.values(imagePromises)).then(() => {
render();
});
resize();
init();
render();
animate();
window.addEventListener("resize", resize);
@ -70,6 +82,10 @@
canvas.height = window.innerHeight;
canvasDpiScaler(canvas, ctx);
if (!animated) {
render();
}
}
const clamp = (val: number, min: number, max: number) =>
@ -190,7 +206,7 @@
ctx.save();
// The source images are black, so we are inverting them
// different amounts to get different shades of gray
ctx.filter = darkTheme ? "invert(0.15)" : "invert(0.8)";
ctx.filter = darkTheme ? "invert(0.1)" : "invert(0.9)";
// Draw center of rotation
// ctx.beginPath();
@ -286,14 +302,14 @@
}
function init() {
/*/
* Calculate the proper amount of particles
* 25920 is our constant, equal to x in (1080*1920)/x = 80
* Because the subjectively correct amount of particles for a 1080p
* display is 80, so to calculate the proper amount for any window size,
* just do (width * height) / 25920
/*/
let particleCount = (window.innerWidth * window.innerHeight) / 25920;
let isMobile = /Mobile|Android|iPhone/i.test(navigator.userAgent);
let particleCount: number;
if (isMobile) {
particleCount = 25;
}
else {
particleCount = 40;
}
particles = [];
for (let i = 0; i < particleCount; i++) {
@ -305,7 +321,7 @@
}
}
function animate() {
function render() {
ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
for (let i_gradient = 0; i_gradient < gradients.length; i_gradient++) {
@ -319,6 +335,12 @@
particle.update();
particle.draw();
}
}
function animate() {
if (animated) {
render();
}
requestAnimationFrame(animate);
}

View File

@ -51,7 +51,7 @@ Svelte modal example, https://svelte.dev/playground/modal
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
<span onclick={modalMenuProcessClick} bind:this={pages} class="modalbg hidden">
<div class={darkTheme ? "dark-theme" : ""}>
<div class={darkTheme() ? "dark-theme" : ""}>
<button onclick={toggleModalMenu} class="close" aria-label="Close">
<i class="bi bi-x"></i>
</button>

View File

@ -17,7 +17,7 @@
let darkTheme = $state(false);
/*/
* This is necesarry for pages to read the theme,
* This is necessary for pages to read the theme,
* sucks that we have to use an anonymous function
* just to grab a variable
/*/

View File

@ -1,2 +1,5 @@
export const prerender = true;
export const csr = true;
export const trailingSlash = "always";
// This will output directories containing index.html

View File

@ -1,7 +1,12 @@
// The magic cookie system is so stupid
export function setCookie(cname: string, cvalue: string) {
document.cookie = cname + "=" + cvalue + ";";
export function setCookie(
cname: string,
cvalue: string,
sameSite: string = "Lax",
) {
document.cookie =
cname + "=" + cvalue + ";" + "SameSite" + "=" + sameSite + ";";
}
// Credit: https://www.w3schools.com/js/js_cookies.asp