beautiful-backgrounds 0.0.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -76
  3. package/build/bb.es.js +3038 -0
  4. package/build/bb.es.js.map +1 -0
  5. package/build/bb.js +9 -0
  6. package/build/bb.js.map +1 -0
  7. package/build/index.d.ts +7 -0
  8. package/build/src/BeautifulBackground.d.ts +25 -0
  9. package/build/src/Particle.d.ts +53 -0
  10. package/build/src/Symbol.d.ts +7 -0
  11. package/build/src/components/ambientRibbon.d.ts +25 -0
  12. package/{dist/components/DigitalRain.d.ts → build/src/components/digitalRain.d.ts} +15 -11
  13. package/build/src/components/hexagonWave.d.ts +29 -0
  14. package/build/src/components/liquidLines.d.ts +24 -0
  15. package/build/src/components/neonRails.d.ts +31 -0
  16. package/build/src/components/startTrail.d.ts +33 -0
  17. package/build/src/stories/AmbientRibbon.stories.d.ts +16 -0
  18. package/build/src/stories/DigitalRain.stories.d.ts +13 -0
  19. package/build/src/stories/HexagonWave.stories.d.ts +19 -0
  20. package/build/src/stories/LiquidLines.stories.d.ts +17 -0
  21. package/build/src/stories/NeonRails.stories.d.ts +20 -0
  22. package/build/src/stories/StartTrail.stories.d.ts +20 -0
  23. package/build/src/utils/color.d.ts +2 -0
  24. package/build/src/utils/function.d.ts +1 -0
  25. package/build/src/utils/lit.d.ts +2 -0
  26. package/{dist → build/src}/utils/number.d.ts +0 -1
  27. package/build/vite.svg +1 -0
  28. package/package.json +53 -27
  29. package/dist/beautiful-backgrounds.min.js +0 -1
  30. package/dist/components/BeautifulBackground.d.ts +0 -28
  31. package/dist/components/BeautifulBackground.js +0 -110
  32. package/dist/components/DigitalRain.js +0 -72
  33. package/dist/components/Particle.d.ts +0 -18
  34. package/dist/components/Particle.js +0 -44
  35. package/dist/components/StarTrail.d.ts +0 -30
  36. package/dist/components/StarTrail.js +0 -95
  37. package/dist/components/Symbol.d.ts +0 -9
  38. package/dist/components/Symbol.js +0 -20
  39. package/dist/index.d.ts +0 -2
  40. package/dist/index.js +0 -2
  41. package/dist/utils/color.d.ts +0 -1
  42. package/dist/utils/color.js +0 -7
  43. package/dist/utils/number.js +0 -20
  44. package/dist/utils/object.js +0 -9
  45. /package/{dist → build/src}/utils/object.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ export * from "./src/BeautifulBackground";
2
+ export * from "./src/components/ambientRibbon";
3
+ export * from "./src/components/digitalRain";
4
+ export * from "./src/components/hexagonWave";
5
+ export * from "./src/components/liquidLines";
6
+ export * from "./src/components/neonRails";
7
+ export * from "./src/components/startTrail";
@@ -0,0 +1,25 @@
1
+ import { LitElement } from "lit";
2
+ export declare abstract class BeautifulBackground extends LitElement {
3
+ bgColors: string[];
4
+ bgAngle: number;
5
+ backgroundColor: string;
6
+ canvas: HTMLCanvasElement;
7
+ ctx: CanvasRenderingContext2D;
8
+ width: number;
9
+ height: number;
10
+ animationFrameId: number | null;
11
+ trailOpacity: number;
12
+ protected debouncedResize: () => void;
13
+ constructor();
14
+ protected handleVisibilityChange: () => void;
15
+ protected firstUpdated(): void;
16
+ disconnectedCallback(): void;
17
+ protected drawBackground(ctx: CanvasRenderingContext2D): void;
18
+ protected resizeCanvas(): void;
19
+ protected initialize(): void;
20
+ protected startAnimation(): void;
21
+ protected stopAnimation(): void;
22
+ static styles: import("lit").CSSResult;
23
+ protected abstract loop(deltaTime: number): void;
24
+ render(): void;
25
+ }
@@ -0,0 +1,53 @@
1
+ export default class Particle {
2
+ private size;
3
+ private speed;
4
+ private color;
5
+ private radius;
6
+ private angle;
7
+ private lifespan;
8
+ private force;
9
+ private x;
10
+ private y;
11
+ private px;
12
+ private py;
13
+ private initialized;
14
+ private frequencyX;
15
+ private frequencyY;
16
+ private born;
17
+ private fadeInDuration;
18
+ private fadeOutDuration;
19
+ constructor(options: ParticleOptions);
20
+ circularMove(centerX: number, centerY: number, deltaTime: number): void;
21
+ sinusMove(centerX: number, centerY: number, deltaTime: number): void;
22
+ draw(ctx: CanvasRenderingContext2D): void;
23
+ isDead(): boolean;
24
+ private gridSides;
25
+ private gridSize;
26
+ private gridAngle;
27
+ private railFromX;
28
+ private railFromY;
29
+ private railToX;
30
+ private railToY;
31
+ private railProgress;
32
+ railMove(centerX: number, centerY: number, deltaTime: number): void;
33
+ private pickNextRailTarget;
34
+ private snapToGrid;
35
+ private updatePosition;
36
+ private calculateOpacity;
37
+ }
38
+ export interface ParticleOptions {
39
+ size: number;
40
+ speed: number;
41
+ color: string;
42
+ radius?: number;
43
+ angle: number;
44
+ lifespan: number;
45
+ force?: number;
46
+ frequencyX?: number;
47
+ frequencyY?: number;
48
+ gridSides?: number;
49
+ gridSize?: number;
50
+ gridAngle?: number;
51
+ x?: number;
52
+ y?: number;
53
+ }
@@ -0,0 +1,7 @@
1
+ export default class Symbol {
2
+ protected x: number;
3
+ protected y: number;
4
+ constructor(x: number, y: number);
5
+ update(height: number, randomness: number, fontSize: number, deltaTime: number, speed: number, baseSpeed?: number): void;
6
+ draw(ctx: CanvasRenderingContext2D, text: string, color: string, fontSize: number, speed: number, baseSpeed?: number): void;
7
+ }
@@ -0,0 +1,25 @@
1
+ import type { PropertyValues } from "lit";
2
+ import { BeautifulBackground } from "../BeautifulBackground";
3
+ export declare class BbAmbientRibbon extends BeautifulBackground {
4
+ ribbonCount: number;
5
+ ribbonWidth: number;
6
+ ribbonRotation: number;
7
+ ribbonHueStart: number;
8
+ ribbonHueEnd: number;
9
+ ribbonSaturationStart: number;
10
+ ribbonSaturationEnd: number;
11
+ ribbonLightnessStart: number;
12
+ ribbonLightnessEnd: number;
13
+ ribbonAmplitude: number;
14
+ ribbonSpeedMin: number;
15
+ ribbonSpeedMax: number;
16
+ ribbonLineWidth: number;
17
+ ribbonLineOpacity: number;
18
+ private ribbons;
19
+ private hue;
20
+ private hueForward;
21
+ protected initialize(): void;
22
+ protected updated(changedProperties: PropertyValues): void;
23
+ private updateColor;
24
+ protected loop(): void;
25
+ }
@@ -1,6 +1,9 @@
1
- import BB from './BeautifulBackground';
2
- import Symbol from './Symbol';
3
- export declare class BbDigitalRain extends BB {
1
+ import Symbol from "../Symbol";
2
+ import { BeautifulBackground } from "../BeautifulBackground";
3
+ export declare class BbDigitalRain extends BeautifulBackground {
4
+ speed: number;
5
+ characters: string;
6
+ randomness: number;
4
7
  fontSize: number;
5
8
  fontColorHueStart: number;
6
9
  fontColorHueEnd: number;
@@ -8,17 +11,18 @@ export declare class BbDigitalRain extends BB {
8
11
  fontColorSaturationEnd: number;
9
12
  fontColorLightnessStart: number;
10
13
  fontColorLightnessEnd: number;
14
+ fontColors: string[];
11
15
  columns: number;
12
- randomness: number;
13
- characters: string;
14
16
  symbols: Symbol[];
15
- static observedAttributes: string[];
16
- protected ignoredProps: string[];
17
17
  constructor();
18
- protected connectedCallback(): void;
19
- protected disconnectedCallback(): void;
20
18
  protected initialize(): void;
21
- protected animation(): void;
19
+ private createSymbols;
20
+ private updateSymbols;
21
+ protected loop(deltaTime: number): void;
22
22
  protected createSymbol(index: number): Symbol;
23
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
23
+ }
24
+ declare global {
25
+ interface HTMLElementTagNameMap {
26
+ "bb-digital-rain": BbDigitalRain;
27
+ }
24
28
  }
@@ -0,0 +1,29 @@
1
+ import { type PropertyValues } from "lit";
2
+ import { BeautifulBackground } from "../BeautifulBackground";
3
+ export declare class BbHexagonWave extends BeautifulBackground {
4
+ hexSize: number;
5
+ waveAmplitude: number;
6
+ waveSpeed: number;
7
+ waveXFactor: number;
8
+ waveYFactor: number;
9
+ shadeAmplitude: number;
10
+ shadeLightnessBoost: number;
11
+ baseLightness: number;
12
+ lightnessRange: number;
13
+ hexHueStart: number;
14
+ hexHueEnd: number;
15
+ hexSaturation: number;
16
+ hexScale: number;
17
+ hexColors: string[];
18
+ private grid;
19
+ private time;
20
+ protected updated(changedProperties: PropertyValues): void;
21
+ protected initialize(): void;
22
+ protected loop(deltaTime: number): void;
23
+ private drawHex;
24
+ }
25
+ declare global {
26
+ interface HTMLElementTagNameMap {
27
+ "bb-hexagon-wave": BbHexagonWave;
28
+ }
29
+ }
@@ -0,0 +1,24 @@
1
+ import { BeautifulBackground } from "../BeautifulBackground";
2
+ export declare class BbLiquidLines extends BeautifulBackground {
3
+ lineCount: number;
4
+ lineAmplitude: number;
5
+ lineFrequency: number;
6
+ speed: number;
7
+ lineSpacing: number;
8
+ lineWidth: number;
9
+ lineHueStart: number;
10
+ lineHueEnd: number;
11
+ lineSaturation: number;
12
+ lineOffsetStep: number;
13
+ wiggleAmplitude: number;
14
+ wiggleSpeed: number;
15
+ lineColors: string[];
16
+ private time;
17
+ protected loop(deltaTime: number): void;
18
+ private drawLine;
19
+ }
20
+ declare global {
21
+ interface HTMLElementTagNameMap {
22
+ "bb-liquid-lines": BbLiquidLines;
23
+ }
24
+ }
@@ -0,0 +1,31 @@
1
+ import Particle from "../Particle";
2
+ import { BeautifulBackground } from "../BeautifulBackground";
3
+ export declare class BbNeonRails extends BeautifulBackground {
4
+ particleSizeMin: number;
5
+ particleSizeMax: number;
6
+ particleSpeedMin: number;
7
+ particleSpeedMax: number;
8
+ particleColorHueStart: number;
9
+ particleColorHueEnd: number;
10
+ particleColorSaturationStart: number;
11
+ particleColorSaturationEnd: number;
12
+ particleColorLightnessStart: number;
13
+ particleColorLightnessEnd: number;
14
+ particleLifespanMin: number;
15
+ particleLifespanMax: number;
16
+ particleAmount: number;
17
+ gridSides: number;
18
+ gridSize: number;
19
+ gridAngle: number;
20
+ particleColors: string[];
21
+ private particles;
22
+ trailOpacity: number;
23
+ protected initialize(): void;
24
+ protected loop(deltaTime: number): void;
25
+ protected createParticle(): Particle;
26
+ }
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ "bb-neon-rails": BbNeonRails;
30
+ }
31
+ }
@@ -0,0 +1,33 @@
1
+ import Particle from "../Particle";
2
+ import { BeautifulBackground } from "../BeautifulBackground";
3
+ export declare class BbStarTrail extends BeautifulBackground {
4
+ particleForce: number;
5
+ particleSizeMin: number;
6
+ particleSizeMax: number;
7
+ particleSpeedMin: number;
8
+ particleSpeedMax: number;
9
+ particleColorHueStart: number;
10
+ particleColorHueEnd: number;
11
+ particleColorSaturationStart: number;
12
+ particleColorSaturationEnd: number;
13
+ particleColorLightnessStart: number;
14
+ particleColorLightnessEnd: number;
15
+ particleRadiusMin: number;
16
+ particleRadiusMax: number;
17
+ particleLifespanMin: number;
18
+ particleLifespanMax: number;
19
+ particleAmount: number;
20
+ gridSides: number;
21
+ gridSize: number;
22
+ gridAngle: number;
23
+ particleColors: string[];
24
+ private particles;
25
+ protected initialize(): void;
26
+ protected loop(deltaTime: number): void;
27
+ protected createParticle(): Particle;
28
+ }
29
+ declare global {
30
+ interface HTMLElementTagNameMap {
31
+ "bb-star-trail": BbStarTrail;
32
+ }
33
+ }
@@ -0,0 +1,16 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components-vite";
2
+ import "../components/ambientRibbon";
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj;
6
+ export declare const SignatureFlow: Story;
7
+ export declare const Colorful: Story;
8
+ export declare const Monochrome: Story;
9
+ export declare const EmeraldForest: Story;
10
+ export declare const GoldenHour: Story;
11
+ export declare const MidnightAura: Story;
12
+ export declare const SoftPastel: Story;
13
+ export declare const NeonGlow: Story;
14
+ export declare const MinimalLines: Story;
15
+ export declare const SunsetFlow: Story;
16
+ export declare const ColdWave: Story;
@@ -0,0 +1,13 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components-vite";
2
+ import "../components/digitalRain";
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj;
6
+ export declare const ClassicMatrixRain: Story;
7
+ export declare const CyberpunkPink: Story;
8
+ export declare const PurpleRain: Story;
9
+ export declare const NeonBlue: Story;
10
+ export declare const OrangeFire: Story;
11
+ export declare const GhostWhite: Story;
12
+ export declare const RainbowChaos: Story;
13
+ export declare const MatrixRed: Story;
@@ -0,0 +1,19 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components-vite";
2
+ import "../components/hexagonWave";
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj;
6
+ export declare const HoneycombPulsar: Story;
7
+ export declare const SunsetGradient: Story;
8
+ export declare const NeonVibe: Story;
9
+ export declare const HoneyCombs: Story;
10
+ export declare const TinyCells: Story;
11
+ export declare const OceanDepths: Story;
12
+ export declare const LavaFlow: Story;
13
+ export declare const ArcticIce: Story;
14
+ export declare const CyberpunkGrid: Story;
15
+ export declare const ForestCanopy: Story;
16
+ export declare const DesertMirage: Story;
17
+ export declare const ElectricStorm: Story;
18
+ export declare const PastelDream: Story;
19
+ export declare const SurfersParadise: Story;
@@ -0,0 +1,17 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components-vite";
2
+ import "../components/liquidLines";
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj;
6
+ export declare const SerpentineFlow: Story;
7
+ export declare const DeepSea: Story;
8
+ export declare const SunsetGlow: Story;
9
+ export declare const NeonPulse: Story;
10
+ export declare const Minimalist: Story;
11
+ export declare const AuroraBorealis: Story;
12
+ export declare const MoltenMagma: Story;
13
+ export declare const DigitalMist: Story;
14
+ export declare const Bioluminescence: Story;
15
+ export declare const GoldenHour: Story;
16
+ export declare const Rainbow: Story;
17
+ export declare const PinkShutters: Story;
@@ -0,0 +1,20 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components-vite";
2
+ import "../components/neonRails";
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj;
6
+ export declare const CyberGridNetwork: Story;
7
+ export declare const LaserSecurityGrid: Story;
8
+ export declare const GoldenMesh: Story;
9
+ export declare const StarRole: Story;
10
+ export declare const Maze: Story;
11
+ export declare const TriangleChain: Story;
12
+ export declare const PinkVeins: Story;
13
+ export declare const ElectricHighway: Story;
14
+ export declare const VioletLattice: Story;
15
+ export declare const TronLegacy: Story;
16
+ export declare const NeuralNetwork: Story;
17
+ export declare const RainbowCircuit: Story;
18
+ export declare const QuantumTunnels: Story;
19
+ export declare const EmeraldMatrix: Story;
20
+ export declare const SunsetGrid: Story;
@@ -0,0 +1,20 @@
1
+ import type { Meta, StoryObj } from "@storybook/web-components-vite";
2
+ import "../components/startTrail";
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj;
6
+ export declare const GalacticVortex: Story;
7
+ export declare const Messiere: Story;
8
+ export declare const PartyLights: Story;
9
+ export declare const BlueFireFlies: Story;
10
+ export declare const CyanRing: Story;
11
+ export declare const GravitationalCollapse: Story;
12
+ export declare const RGBStars: Story;
13
+ export declare const GoldenNebula: Story;
14
+ export declare const AuroraBorealis: Story;
15
+ export declare const CosmicDust: Story;
16
+ export declare const FireflyForest: Story;
17
+ export declare const NeonVortex: Story;
18
+ export declare const StarfieldWarp: Story;
19
+ export declare const TwilightSparkle: Story;
20
+ export declare const RainbowBurst: Story;
@@ -0,0 +1,2 @@
1
+ export declare function randomColor(hRange?: number[], sRange?: number[], lRange?: number[]): string;
2
+ export declare function hsla(hue: number, saturation: number, lightness: number, opacity: number): string;
@@ -0,0 +1 @@
1
+ export declare function debounce(func: Function, wait: number): (...args: any[]) => void;
@@ -0,0 +1,2 @@
1
+ import type { ComplexAttributeConverter } from "lit";
2
+ export declare const stringToArrayConverter: ComplexAttributeConverter<string[]>;
@@ -1,3 +1,2 @@
1
1
  export declare function getRandomFloat(min: number, max: number): number;
2
2
  export declare function getRandomInt(min: number, max: number): number;
3
- export declare function interpolateLinear(value: number, domainStart: number, domainEnd: number, rangeStart: number, rangeEnd: number): number;
package/build/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,11 +1,58 @@
1
1
  {
2
2
  "name": "beautiful-backgrounds",
3
- "version": "0.0.6",
3
+ "version": "1.0.0",
4
+ "type": "module",
4
5
  "repository": {
5
6
  "type": "git",
6
- "url": "https://github.com/Niekes/beautiful-backgrounds"
7
+ "url": "git+https://github.com/niekes/beautiful-backgrounds.git"
8
+ },
9
+ "main": "./build/bb.js",
10
+ "module": "./build/bb.es.js",
11
+ "types": "./build/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./build/index.d.ts",
15
+ "import": "./build/bb.es.js",
16
+ "require": "./build/bb.js"
17
+ }
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "files": [
23
+ "build",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "scripts": {
28
+ "dev": "vite",
29
+ "build": "tsc && vite build",
30
+ "build:types": "tsc --emitDeclarationOnly --declaration --outDir build",
31
+ "preview": "vite preview",
32
+ "storybook": "storybook dev -p 6006",
33
+ "build-storybook": "storybook build"
34
+ },
35
+ "dependencies": {},
36
+ "peerDependencies": {
37
+ "lit": "^3.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@storybook/addon-a11y": "^10.2.0",
41
+ "@storybook/addon-docs": "^10.2.0",
42
+ "@storybook/addon-vitest": "^10.2.0",
43
+ "@storybook/web-components-vite": "^10.2.0",
44
+ "@types/d3": "^7.4.3",
45
+ "@types/node": "^25.0.10",
46
+ "@vitest/browser-playwright": "^4.0.17",
47
+ "@vitest/coverage-v8": "^4.0.17",
48
+ "d3": "^7.9.0",
49
+ "playwright": "^1.57.0",
50
+ "storybook": "^10.2.0",
51
+ "typescript": "~5.9.3",
52
+ "vite": "^7.2.4",
53
+ "vitest": "^4.0.17",
54
+ "lit": "^3.3.1"
7
55
  },
8
- "homepage": "https://github.com/Niekes/beautiful-backgrounds#readme",
9
56
  "keywords": [
10
57
  "canvas",
11
58
  "animation",
@@ -24,28 +71,7 @@
24
71
  "beautiful-backgrounds",
25
72
  "html5-canvas"
26
73
  ],
27
- "author": "Niekes (https://niekes.com)",
28
- "license": "BSD-3-Clause",
29
- "description": "A collection of customizable web components for creating dynamic, animated backgrounds, featuring a variety of effects including a star field and a digital rain. ",
30
- "type": "module",
31
- "main": "dist/index.js",
32
- "types": "dist/index.d.ts",
33
- "scripts": {
34
- "clean": "rm -rf dist",
35
- "pretest": "npx tsc",
36
- "test": "c8 --reporter lcov tape tests/**/*.js",
37
- "build": "npm run clean && npx tsc && rollup -c",
38
- "watch": "npm run clean && npx tsc --watch",
39
- "release": "npm run clean && npm run build && git push --follow-tags && npm publish"
40
- },
41
- "files": [
42
- "dist/"
43
- ],
44
- "devDependencies": {
45
- "@rollup/plugin-terser": "^0.4.4",
46
- "c8": "^8.0.1",
47
- "rollup": "^4.6.1",
48
- "tape": "^5.7.2",
49
- "typescript": "5.3.2"
50
- }
74
+ "author": "Niekes",
75
+ "license": "MIT",
76
+ "description": "A collection of customizable web components for creating dynamic, animated backgrounds, featuring a variety of effects including a star field and a digital rain. "
51
77
  }
@@ -1 +0,0 @@
1
- !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).version={})}(this,(function(t){"use strict";class i extends HTMLElement{constructor(){super(),this.interpolationDuration=1e3,this.interpolationStep=100,this.fullyInitialized=!1,this.shadowR=this.attachShadow({mode:"open"}),this.shadowR.innerHTML="\n <style>\n :host {\n display: flex;\n }\n </style>\n ",this.lastTime=0,this.fps=30,this.timer=0,this.resizeDebounceTimer=null,this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.backgroundColor="0, 0, 0"}debouncedResizeCanvas(){clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=setTimeout((()=>{this.resizeCanvas()}),1e3)}startAnimation(t){const i=s=>{const a=s-this.lastTime;this.lastTime=s,this.timer>1e3/this.fps?(t(),this.timer=0):this.timer+=a,this.animationFrameId=requestAnimationFrame(i)};this.animationFrameId=requestAnimationFrame(i)}interpolateWithThrottle(t,i,s,a,e){const n=Math.ceil(s/a),r=(i-t)/n;let o=t,h=0,l=!0,d=null;!function t(){h<s&&l?(e(o,!1),o+=r,h+=a,d=window.setTimeout(t,a)):l&&(e(i,!0),l=!1,d&&window.clearTimeout(d))}()}triggerInterpolation(t,i,s){const a=Number(i),e=Number(s),n=this.getPropNameCamelCased(t);var r,o;a!==e&&this.fullyInitialized?(r=this,o=n,Object.prototype.hasOwnProperty.call(r,o)&&this.interpolateWithThrottle(i?a:this[n],e,this.interpolationDuration,this.interpolationStep,(t=>{this[n]=t}))):this[n]=e}setValues(t,i,s,a){if(t.includes(i)){this[this.getPropNameCamelCased(i)]=a}t.includes(i)||this.triggerInterpolation(i,s,a)}getPropNameCamelCased(t){return t.substring(5).replace(/-(.)/g,((t,i)=>i.toUpperCase()))}resizeCanvas(){const t=Number.parseInt(this.getAttribute("data-width"))||this.parentElement.clientWidth,i=Number.parseInt(this.getAttribute("data-height"))||this.parentElement.clientHeight;t===this.width&&i===this.height||(this.width=t,this.height=i,this.canvas.width=t,this.canvas.height=i,this.canvas.style.backgroundColor=`rgb(${this.backgroundColor})`),this.fullyInitialized=!0}}class s{constructor(t,i,s,a,e,n){this.size=t,this.speed=i,this.color=s,this.radius=a,this.angle=e,this.lifespan=n,this.x=0,this.y=0,this.born=Date.now(),this.fadeInDuration=.25*this.lifespan,this.fadeOutDuration=.5*this.lifespan}update(t,i){this.angle+=this.speed,this.x=t+Math.cos(this.angle)*this.radius,this.y=i+Math.sin(this.angle)*this.radius}draw(t){t.beginPath(),t.arc(this.x,this.y,this.size,0,2*Math.PI,!1),t.fillStyle=this.color,t.globalAlpha=this.calculateOpacity(),t.shadowBlur=10,t.shadowColor=this.color,t.fill(),t.globalAlpha=1,t.shadowBlur=0}isDead(){return Date.now()-this.born>this.lifespan}calculateOpacity(){const t=Date.now()-this.born;return t<this.fadeInDuration?t/this.fadeInDuration:t>this.lifespan-this.fadeOutDuration?(this.lifespan-t)/this.fadeOutDuration:1}}function a(t,i){return Math.random()*(i-t)+t}function e(t,i){return t=Math.ceil(t),i=Math.floor(i),Math.floor(Math.random()*(i-t+1)+t)}function n(t,i,s,a,e){t<i&&(t=i),t>s&&(t=s);return(t-i)/(s-i)*(e-a)+a}function r(t=[0,360],i=[0,100],s=[40,60]){return`hsl(${e(t[0],t[1])}, ${e(i[0],i[1])}%, ${e(s[0],s[1])}%)`}class o extends i{constructor(){super(),this.ignoredProps=["data-characters","data-background-color"],this.backgroundColor="0, 0, 0",this.starSizeMin=.5,this.starSizeMax=1.5,this.starSpeedMin=.025,this.starSpeedMax=.05,this.starColorHueStart=30,this.starColorHueEnd=75,this.starColorSaturationStart=100,this.starColorSaturationEnd=100,this.starColorLightnessStart=50,this.starColorLightnessEnd=50,this.starRadiusMin=1,this.starRadiusMax=100,this.starLifespanMin=1e3,this.starLifespanMax=1e4,this.numStars=1e3,this.trailOpacity=.1}connectedCallback(){this.shadowR.appendChild(this.canvas),this.resizeCanvas(),this.initialize(),this.startAnimation(this.animation.bind(this)),window.addEventListener("resize",this.debouncedResizeCanvas.bind(this))}disconnectedCallback(){window.removeEventListener("resize",this.debouncedResizeCanvas.bind(this)),null!==this.animationFrameId&&window.cancelAnimationFrame(this.animationFrameId)}initialize(){this.stars=[],this.starRadiusMax=Math.max(this.width,this.height)/2,this.animationFrameId=null;for(let t=0;t<this.numStars;t++)this.stars.push(this.createStar())}animation(){for(this.ctx.fillStyle=`rgba(${this.backgroundColor}, ${this.trailOpacity})`,this.ctx.fillRect(0,0,this.width,this.height),this.stars=this.stars.filter((t=>!t.isDead()));this.stars.length<this.numStars;)this.stars.push(this.createStar());this.stars.forEach((t=>{t.update(this.width/2,this.height/2),t.draw(this.ctx)}))}createStar(){const t=a(this.starSizeMin,this.starSizeMax),i=a(n(this.starSpeedMin,-1,1,-.04,.04),n(this.starSpeedMax,-1,1,-.04,.04)),e=a(this.starLifespanMin,this.starLifespanMax),o=r([this.starColorHueStart,this.starColorHueEnd],[this.starColorSaturationStart,this.starColorSaturationEnd],[this.starColorLightnessStart,this.starColorLightnessEnd]),h=a(0,2*Math.PI),l=this.starRadiusMax-this.starRadiusMin,d=Math.sqrt(Math.random())*l+this.starRadiusMin;return new s(t,i,o,d,h,e)}attributeChangedCallback(t,i,s){this.setValues(this.ignoredProps,t,i,s)}}o.observedAttributes=["data-fps","data-background-color","data-star-size-min","data-star-size-max","data-star-speed-min","data-star-speed-max","data-star-color-hue-start","data-star-color-hue-end","data-star-color-saturation-start","data-star-color-saturation-end","data-star-color-lightness-start","data-star-color-lightness-end","data-star-radius-min","data-star-radius-max","data-star-lifespan-min","data-star-lifespan-max","data-num-stars"],window.customElements.get("bb-star-trail")||window.customElements.define("bb-star-trail",o);class h{constructor(t,i,s,a="#0f0"){this.x=t,this.y=i,this.fontSize=s,this.color=a}update(t,i){this.y*this.fontSize>t&&Math.random()>i?this.y=0:this.y+=1}draw(t,i){t.fillStyle=this.color,t.fillText(i,this.x*this.fontSize,this.y*this.fontSize)}}class l extends i{constructor(){super(),this.ignoredProps=["data-characters","data-background-color"],this.fontSize=24,this.fontColorHueStart=60,this.fontColorHueEnd=this.fontColorHueStart+90,this.fontColorSaturationStart=90,this.fontColorSaturationEnd=100,this.fontColorLightnessStart=50,this.fontColorLightnessEnd=50,this.randomness=.975,this.trailOpacity=.1,this.characters='ヲアウエオカキケコサシスセソタツテナニヌネハヒホマミムメモヤユラリワ13579ヲイクコソチトノフヤヨルレロンZ:."¦=*+-<>|リçδ╘'}connectedCallback(){this.shadowR.appendChild(this.canvas),this.resizeCanvas(),this.initialize(),this.startAnimation(this.animation.bind(this)),window.addEventListener("resize",this.debouncedResizeCanvas.bind(this))}disconnectedCallback(){window.removeEventListener("resize",this.debouncedResizeCanvas.bind(this)),null!==this.animationFrameId&&window.cancelAnimationFrame(this.animationFrameId)}initialize(){this.symbols=[],this.columns=Math.floor(this.width/this.fontSize);for(let t=0;t<this.columns;t++)this.symbols[t]=this.createSymbol(t)}animation(){this.ctx.fillStyle=`rgba(${this.backgroundColor}, ${this.trailOpacity})`,this.ctx.fillRect(0,0,this.width,this.height),this.ctx.textAlign="center",this.ctx.font=`${this.fontSize}px monospace`,this.symbols.forEach((t=>{t.draw(this.ctx,this.characters.charAt(Math.floor(Math.random()*this.characters.length))),t.update(this.height,this.randomness)}))}createSymbol(t){return new h(t,e(0,-this.height/this.fontSize),this.fontSize,r([this.fontColorHueStart,this.fontColorHueEnd],[this.fontColorSaturationStart,this.fontColorSaturationEnd],[this.fontColorLightnessStart,this.fontColorLightnessEnd]))}attributeChangedCallback(t,i,s){this.setValues(this.ignoredProps,t,i,s)}}l.observedAttributes=["data-fps","data-characters","data-randomness","data-font-size","data-font-color-hue-start","data-font-color-hue-end","data-font-color-saturation-start","data-font-color-saturation-end","data-font-color-lightness-start","data-font-color-lightness-end","data-background-color"],window.customElements.get("bb-digital-rain")||window.customElements.define("bb-digital-rain",l),t.BbDigitalRain=l,t.BbStarTrail=o}));
@@ -1,28 +0,0 @@
1
- export default abstract class BeautifulBackground extends HTMLElement {
2
- protected shadowR: ShadowRoot;
3
- protected width: number;
4
- protected height: number;
5
- protected canvas: HTMLCanvasElement;
6
- protected ctx: CanvasRenderingContext2D;
7
- protected backgroundColor: string;
8
- protected trailOpacity: number;
9
- protected lastTime: number;
10
- protected fps: number;
11
- protected timer: number;
12
- protected animationFrameId: number | null;
13
- private resizeDebounceTimer;
14
- private interpolationDuration;
15
- private interpolationStep;
16
- private fullyInitialized;
17
- constructor();
18
- protected abstract connectedCallback(): void;
19
- protected abstract disconnectedCallback(): void;
20
- protected abstract initialize(): void;
21
- protected debouncedResizeCanvas(): void;
22
- protected startAnimation(fn: Function): void;
23
- protected interpolateWithThrottle(startValue: number, newValue: number, durationMs: number, throttleMs: number, onInterpolate: Function): void;
24
- protected triggerInterpolation(name: string, oldValue: string, newValue: string): void;
25
- protected setValues(ignoredProps: string[], name: string, oldValue: string, newValue: string): void;
26
- protected getPropNameCamelCased(dashCased: string): string;
27
- protected resizeCanvas(): void;
28
- }