Added landscape wallpaper

This commit is contained in:
Dustin Brett 2022-06-08 19:36:20 -07:00
parent 2249f2aae0
commit 75e5efd96e
7 changed files with 7050 additions and 0 deletions

View File

@ -0,0 +1,30 @@
import { loadFiles } from "utils/functions";
declare global {
interface Window {
effectInit: (canvas: HTMLCanvasElement) => void;
}
}
export const libs = [
"/System/ShaderToy/CoastalLandscape/piLibs.js",
"/System/ShaderToy/CoastalLandscape/effect.js",
"/System/ShaderToy/CoastalLandscape/init.js",
];
const CoastalLandscape = async (el?: HTMLElement | null): Promise<void> => {
if (!el) return;
await loadFiles(libs);
const canvas = document.createElement("canvas");
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
window.effectInit(canvas);
el.appendChild(canvas);
};
export default CoastalLandscape;

View File

@ -0,0 +1,33 @@
import { libs } from "components/system/Desktop/Wallpapers/ShaderToy/CoastalLandscape";
import type { OffscreenRenderProps } from "components/system/Desktop/Wallpapers/types";
import { isWebGLAvailable } from "utils/functions";
/* eslint-disable vars-on-top, no-var */
declare global {
var effectInit: (canvas: OffscreenCanvas) => void;
var updateLandscapeSize: () => void;
var demoCanvasRect: DOMRect;
var devicePixelRatio: number;
}
/* eslint-enable vars-on-top, no-var */
globalThis.addEventListener(
"message",
({ data }: { data: DOMRect | OffscreenRenderProps | string }) => {
if (!isWebGLAvailable) return;
if (data === "init") {
globalThis.importScripts(...libs);
} else if (data instanceof DOMRect) {
globalThis.demoCanvasRect = data;
globalThis.updateLandscapeSize();
} else {
const { canvas, devicePixelRatio } = data as OffscreenRenderProps;
globalThis.devicePixelRatio = devicePixelRatio;
globalThis.effectInit(canvas);
}
},
{ passive: true }
);

View File

@ -1,4 +1,5 @@
import hexells from "components/system/Desktop/Wallpapers/hexells";
import coastalLandscape from "components/system/Desktop/Wallpapers/ShaderToy/CoastalLandscape";
import vantaWaves from "components/system/Desktop/Wallpapers/vantaWaves";
import { config } from "components/system/Desktop/Wallpapers/vantaWaves/config";
import { useFileSystem } from "contexts/fileSystem";
@ -29,6 +30,14 @@ const cssFit: Record<WallpaperFit, string> = {
};
const WALLPAPER_WORKERS: Record<string, () => Worker> = {
COASTAL_LANDSCAPE: (): Worker =>
new Worker(
new URL(
"components/system/Desktop/Wallpapers/ShaderToy/CoastalLandscape/wallpaper.worker",
import.meta.url
),
{ name: "Wallpaper (Coastal Landscape)" }
),
HEXELLS: (): Worker =>
new Worker(
new URL(
@ -83,6 +92,8 @@ const useWallpaper = (
vantaWaves(config)(desktopRef.current);
} else if (wallpaperImage === "HEXELLS") {
hexells(desktopRef.current);
} else if (wallpaperImage === "COASTAL_LANDSCAPE") {
coastalLandscape(desktopRef.current);
} else {
setWallpaper("VANTA");
}

View File

@ -106,6 +106,11 @@ const useFolderContextMenu = (
label: "APOD",
toggle: wallpaperImage.startsWith("APOD"),
},
{
action: () => setWallpaper("COASTAL_LANDSCAPE"),
label: "Coastal Landscape",
toggle: wallpaperImage === "COASTAL_LANDSCAPE",
},
{
action: () => setWallpaper("HEXELLS"),
label: "Hexells",

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff