@autumnsgrove/gossamer 0.0.1 → 0.1.1
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.
- package/dist/animation.d.ts +80 -0
- package/dist/animation.d.ts.map +1 -0
- package/dist/characters.d.ts +49 -0
- package/dist/characters.d.ts.map +1 -0
- package/dist/colors.d.ts +312 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/index.d.ts +39 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1826 -2
- package/dist/index.js.map +1 -1
- package/dist/patterns.d.ts +217 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/renderer.d.ts +140 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/style.css +124 -0
- package/dist/svelte/GossamerBorder.svelte.d.ts +1 -0
- package/dist/svelte/GossamerClouds.svelte.d.ts +1 -0
- package/dist/svelte/GossamerImage.svelte.d.ts +1 -0
- package/dist/svelte/GossamerOverlay.svelte.d.ts +1 -0
- package/dist/svelte/GossamerText.svelte.d.ts +1 -0
- package/dist/svelte/index.d.ts +20 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +3648 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/presets.d.ts +38 -0
- package/dist/svelte/presets.d.ts.map +1 -0
- package/dist/utils/canvas.d.ts +73 -0
- package/dist/utils/canvas.d.ts.map +1 -0
- package/dist/utils/image.d.ts +74 -0
- package/dist/utils/image.d.ts.map +1 -0
- package/dist/utils/performance.d.ts +86 -0
- package/dist/utils/performance.d.ts.map +1 -0
- package/package.json +34 -7
- package/src/animation.test.ts +254 -0
- package/src/animation.ts +243 -0
- package/src/characters.test.ts +148 -0
- package/src/characters.ts +219 -0
- package/src/colors.ts +234 -0
- package/src/index.test.ts +115 -0
- package/src/index.ts +164 -11
- package/src/patterns.test.ts +273 -0
- package/src/patterns.ts +760 -0
- package/src/renderer.ts +470 -0
- package/src/svelte/GossamerBorder.svelte +326 -0
- package/src/svelte/GossamerClouds.svelte +269 -0
- package/src/svelte/GossamerImage.svelte +266 -0
- package/src/svelte/GossamerOverlay.svelte +232 -0
- package/src/svelte/GossamerText.svelte +239 -0
- package/src/svelte/index.ts +75 -0
- package/src/svelte/presets.ts +174 -0
- package/src/utils/canvas.ts +210 -0
- package/src/utils/image.ts +275 -0
- package/src/utils/performance.ts +282 -0
package/src/colors.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gossamer Color Palettes
|
|
3
|
+
*
|
|
4
|
+
* Grove-themed color palettes for ASCII effects.
|
|
5
|
+
* Designed to complement Glass UI components.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Color definition with metadata
|
|
10
|
+
*/
|
|
11
|
+
export interface ColorDef {
|
|
12
|
+
/** Hex color value */
|
|
13
|
+
hex: string;
|
|
14
|
+
/** Human-readable name */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Recommended opacity for glass overlays (0-1) */
|
|
17
|
+
glassOpacity?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Grove Green palette - Primary brand colors
|
|
22
|
+
*/
|
|
23
|
+
export const GROVE_GREEN = {
|
|
24
|
+
50: { hex: '#f0fdf4', name: 'Grove Green 50', glassOpacity: 0.3 },
|
|
25
|
+
100: { hex: '#dcfce7', name: 'Grove Green 100', glassOpacity: 0.25 },
|
|
26
|
+
200: { hex: '#bbf7d0', name: 'Grove Green 200', glassOpacity: 0.2 },
|
|
27
|
+
300: { hex: '#86efac', name: 'Grove Green 300', glassOpacity: 0.18 },
|
|
28
|
+
400: { hex: '#4ade80', name: 'Grove Green 400', glassOpacity: 0.15 },
|
|
29
|
+
500: { hex: '#22c55e', name: 'Grove Green 500', glassOpacity: 0.12 },
|
|
30
|
+
600: { hex: '#16a34a', name: 'Grove Green 600', glassOpacity: 0.1 },
|
|
31
|
+
700: { hex: '#15803d', name: 'Grove Green 700', glassOpacity: 0.1 },
|
|
32
|
+
800: { hex: '#166534', name: 'Grove Green 800', glassOpacity: 0.08 },
|
|
33
|
+
900: { hex: '#14532d', name: 'Grove Green 900', glassOpacity: 0.08 },
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Cream palette - Light/warm backgrounds
|
|
38
|
+
*/
|
|
39
|
+
export const CREAM = {
|
|
40
|
+
50: { hex: '#fefdfb', name: 'Cream 50', glassOpacity: 0.4 },
|
|
41
|
+
100: { hex: '#fdfcf8', name: 'Cream 100', glassOpacity: 0.35 },
|
|
42
|
+
200: { hex: '#faf8f3', name: 'Cream 200', glassOpacity: 0.3 },
|
|
43
|
+
300: { hex: '#f5f2ea', name: 'Cream 300', glassOpacity: 0.25 },
|
|
44
|
+
400: { hex: '#ede9de', name: 'Cream 400', glassOpacity: 0.2 },
|
|
45
|
+
500: { hex: '#e2ddd0', name: 'Cream 500', glassOpacity: 0.18 },
|
|
46
|
+
600: { hex: '#d4cec0', name: 'Cream 600', glassOpacity: 0.15 },
|
|
47
|
+
700: { hex: '#c4bdb0', name: 'Cream 700', glassOpacity: 0.12 },
|
|
48
|
+
800: { hex: '#b0a99c', name: 'Cream 800', glassOpacity: 0.1 },
|
|
49
|
+
900: { hex: '#9a9387', name: 'Cream 900', glassOpacity: 0.08 },
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Bark palette - Dark/earth tones
|
|
54
|
+
*/
|
|
55
|
+
export const BARK = {
|
|
56
|
+
50: { hex: '#faf7f5', name: 'Bark 50', glassOpacity: 0.3 },
|
|
57
|
+
100: { hex: '#f0ebe6', name: 'Bark 100', glassOpacity: 0.25 },
|
|
58
|
+
200: { hex: '#e0d5cc', name: 'Bark 200', glassOpacity: 0.2 },
|
|
59
|
+
300: { hex: '#ccb59c', name: 'Bark 300', glassOpacity: 0.18 },
|
|
60
|
+
400: { hex: '#b89a7a', name: 'Bark 400', glassOpacity: 0.15 },
|
|
61
|
+
500: { hex: '#a57c5a', name: 'Bark 500', glassOpacity: 0.12 },
|
|
62
|
+
600: { hex: '#8a6344', name: 'Bark 600', glassOpacity: 0.1 },
|
|
63
|
+
700: { hex: '#6f4d39', name: 'Bark 700', glassOpacity: 0.1 },
|
|
64
|
+
800: { hex: '#553a2a', name: 'Bark 800', glassOpacity: 0.08 },
|
|
65
|
+
900: { hex: '#3d2914', name: 'Bark 900', glassOpacity: 0.06 },
|
|
66
|
+
} as const;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Status colors
|
|
70
|
+
*/
|
|
71
|
+
export const STATUS = {
|
|
72
|
+
success: { hex: '#22c55e', name: 'Success', glassOpacity: 0.12 },
|
|
73
|
+
warning: { hex: '#f59e0b', name: 'Warning', glassOpacity: 0.12 },
|
|
74
|
+
error: { hex: '#dc2626', name: 'Error', glassOpacity: 0.1 },
|
|
75
|
+
info: { hex: '#0ea5e9', name: 'Info', glassOpacity: 0.12 },
|
|
76
|
+
} as const;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Combined Grove color schemes for easy access
|
|
80
|
+
*/
|
|
81
|
+
export const GROVE_COLORS = {
|
|
82
|
+
// Greens
|
|
83
|
+
grove: GROVE_GREEN[500].hex,
|
|
84
|
+
'grove-light': GROVE_GREEN[300].hex,
|
|
85
|
+
'grove-dark': GROVE_GREEN[700].hex,
|
|
86
|
+
'grove-muted': GROVE_GREEN[400].hex,
|
|
87
|
+
|
|
88
|
+
// Creams
|
|
89
|
+
cream: CREAM[50].hex,
|
|
90
|
+
'cream-warm': CREAM[200].hex,
|
|
91
|
+
'cream-deep': CREAM[500].hex,
|
|
92
|
+
|
|
93
|
+
// Barks
|
|
94
|
+
bark: BARK[900].hex,
|
|
95
|
+
'bark-light': BARK[500].hex,
|
|
96
|
+
'bark-medium': BARK[700].hex,
|
|
97
|
+
|
|
98
|
+
// Utility
|
|
99
|
+
white: '#ffffff',
|
|
100
|
+
black: '#000000',
|
|
101
|
+
transparent: 'transparent',
|
|
102
|
+
} as const;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Glass-optimized color schemes
|
|
106
|
+
* Pre-configured for use with Glass components
|
|
107
|
+
*/
|
|
108
|
+
export const GLASS_SCHEMES = {
|
|
109
|
+
// Light mode schemes (on light backgrounds)
|
|
110
|
+
'grove-mist': {
|
|
111
|
+
color: GROVE_GREEN[500].hex,
|
|
112
|
+
background: 'transparent',
|
|
113
|
+
opacity: 0.12,
|
|
114
|
+
description: 'Subtle green mist for light glass',
|
|
115
|
+
},
|
|
116
|
+
'cream-haze': {
|
|
117
|
+
color: CREAM[600].hex,
|
|
118
|
+
background: 'transparent',
|
|
119
|
+
opacity: 0.15,
|
|
120
|
+
description: 'Warm cream haze for cozy glass',
|
|
121
|
+
},
|
|
122
|
+
'bark-shadow': {
|
|
123
|
+
color: BARK[700].hex,
|
|
124
|
+
background: 'transparent',
|
|
125
|
+
opacity: 0.08,
|
|
126
|
+
description: 'Soft earth shadow for depth',
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
// Dark mode schemes (on dark backgrounds)
|
|
130
|
+
'grove-glow': {
|
|
131
|
+
color: GROVE_GREEN[400].hex,
|
|
132
|
+
background: '#1a1915',
|
|
133
|
+
opacity: 0.15,
|
|
134
|
+
description: 'Glowing green for dark glass',
|
|
135
|
+
},
|
|
136
|
+
'cream-dust': {
|
|
137
|
+
color: CREAM[300].hex,
|
|
138
|
+
background: '#1a1915',
|
|
139
|
+
opacity: 0.1,
|
|
140
|
+
description: 'Dusty cream particles in dark',
|
|
141
|
+
},
|
|
142
|
+
'moonlight': {
|
|
143
|
+
color: '#e2e8f0',
|
|
144
|
+
background: '#1a1915',
|
|
145
|
+
opacity: 0.08,
|
|
146
|
+
description: 'Cool moonlight glow',
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
// Accent schemes
|
|
150
|
+
'spring-fresh': {
|
|
151
|
+
color: GROVE_GREEN[300].hex,
|
|
152
|
+
background: 'transparent',
|
|
153
|
+
opacity: 0.18,
|
|
154
|
+
description: 'Fresh spring green overlay',
|
|
155
|
+
},
|
|
156
|
+
'autumn-warm': {
|
|
157
|
+
color: '#d97706',
|
|
158
|
+
background: 'transparent',
|
|
159
|
+
opacity: 0.1,
|
|
160
|
+
description: 'Warm autumn amber tones',
|
|
161
|
+
},
|
|
162
|
+
'winter-frost': {
|
|
163
|
+
color: '#93c5fd',
|
|
164
|
+
background: 'transparent',
|
|
165
|
+
opacity: 0.12,
|
|
166
|
+
description: 'Cool frost blue overlay',
|
|
167
|
+
},
|
|
168
|
+
} as const;
|
|
169
|
+
|
|
170
|
+
export type GroveColorName = keyof typeof GROVE_COLORS;
|
|
171
|
+
export type GlassSchemeName = keyof typeof GLASS_SCHEMES;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Get a Grove color by name
|
|
175
|
+
*/
|
|
176
|
+
export function getGroveColor(name: GroveColorName | string): string {
|
|
177
|
+
if (name in GROVE_COLORS) {
|
|
178
|
+
return GROVE_COLORS[name as GroveColorName];
|
|
179
|
+
}
|
|
180
|
+
// If it's already a hex color, return it
|
|
181
|
+
if (name.startsWith('#')) {
|
|
182
|
+
return name;
|
|
183
|
+
}
|
|
184
|
+
// Default to grove green
|
|
185
|
+
return GROVE_COLORS.grove;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Get a glass scheme by name
|
|
190
|
+
*/
|
|
191
|
+
export function getGlassScheme(name: GlassSchemeName | string): {
|
|
192
|
+
color: string;
|
|
193
|
+
background: string;
|
|
194
|
+
opacity: number;
|
|
195
|
+
} {
|
|
196
|
+
if (name in GLASS_SCHEMES) {
|
|
197
|
+
const scheme = GLASS_SCHEMES[name as GlassSchemeName];
|
|
198
|
+
return {
|
|
199
|
+
color: scheme.color,
|
|
200
|
+
background: scheme.background,
|
|
201
|
+
opacity: scheme.opacity,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// Default to grove-mist
|
|
205
|
+
return {
|
|
206
|
+
color: GLASS_SCHEMES['grove-mist'].color,
|
|
207
|
+
background: GLASS_SCHEMES['grove-mist'].background,
|
|
208
|
+
opacity: GLASS_SCHEMES['grove-mist'].opacity,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* List all Grove color names
|
|
214
|
+
*/
|
|
215
|
+
export function getGroveColorNames(): string[] {
|
|
216
|
+
return Object.keys(GROVE_COLORS);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* List all glass scheme names
|
|
221
|
+
*/
|
|
222
|
+
export function getGlassSchemeNames(): string[] {
|
|
223
|
+
return Object.keys(GLASS_SCHEMES);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Apply opacity to a hex color, returning rgba string
|
|
228
|
+
*/
|
|
229
|
+
export function hexToRgba(hex: string, opacity: number): string {
|
|
230
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
231
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
232
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
233
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
234
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for core index functions
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import {
|
|
6
|
+
calculateBrightness,
|
|
7
|
+
brightnessToChar,
|
|
8
|
+
DEFAULT_CHARACTERS,
|
|
9
|
+
DEFAULT_CONFIG,
|
|
10
|
+
VERSION,
|
|
11
|
+
} from './index';
|
|
12
|
+
|
|
13
|
+
describe('calculateBrightness', () => {
|
|
14
|
+
it('should return 0 for black', () => {
|
|
15
|
+
expect(calculateBrightness(0, 0, 0)).toBe(0);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should return 255 for white', () => {
|
|
19
|
+
expect(calculateBrightness(255, 255, 255)).toBeCloseTo(255, 5);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should weight green highest', () => {
|
|
23
|
+
// Green contributes 0.72, so pure green should be brighter than pure red
|
|
24
|
+
const greenBrightness = calculateBrightness(0, 255, 0);
|
|
25
|
+
const redBrightness = calculateBrightness(255, 0, 0);
|
|
26
|
+
const blueBrightness = calculateBrightness(0, 0, 255);
|
|
27
|
+
|
|
28
|
+
expect(greenBrightness).toBeGreaterThan(redBrightness);
|
|
29
|
+
expect(greenBrightness).toBeGreaterThan(blueBrightness);
|
|
30
|
+
expect(redBrightness).toBeGreaterThan(blueBrightness);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should calculate correct luminance values', () => {
|
|
34
|
+
// Pure red: 0.21 * 255 = 53.55
|
|
35
|
+
expect(calculateBrightness(255, 0, 0)).toBeCloseTo(53.55, 1);
|
|
36
|
+
// Pure green: 0.72 * 255 = 183.6
|
|
37
|
+
expect(calculateBrightness(0, 255, 0)).toBeCloseTo(183.6, 1);
|
|
38
|
+
// Pure blue: 0.07 * 255 = 17.85
|
|
39
|
+
expect(calculateBrightness(0, 0, 255)).toBeCloseTo(17.85, 1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should handle mid-gray', () => {
|
|
43
|
+
const gray = calculateBrightness(128, 128, 128);
|
|
44
|
+
// 128 * (0.21 + 0.72 + 0.07) = 128
|
|
45
|
+
expect(gray).toBe(128);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('brightnessToChar', () => {
|
|
50
|
+
it('should return space for brightness 0', () => {
|
|
51
|
+
expect(brightnessToChar(0)).toBe(' ');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should return last character for brightness 255', () => {
|
|
55
|
+
expect(brightnessToChar(255)).toBe('@');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should map mid-brightness to middle character', () => {
|
|
59
|
+
// With ' .:-=+*#%@' (10 chars), brightness 127-128 should be around index 4-5
|
|
60
|
+
const char = brightnessToChar(127);
|
|
61
|
+
expect(['=', '+'].includes(char)).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should use custom character set', () => {
|
|
65
|
+
const customSet = ' abc';
|
|
66
|
+
expect(brightnessToChar(0, customSet)).toBe(' ');
|
|
67
|
+
expect(brightnessToChar(255, customSet)).toBe('c');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should handle two-character set', () => {
|
|
71
|
+
const binarySet = ' #';
|
|
72
|
+
expect(brightnessToChar(0, binarySet)).toBe(' ');
|
|
73
|
+
expect(brightnessToChar(127, binarySet)).toBe(' ');
|
|
74
|
+
expect(brightnessToChar(255, binarySet)).toBe('#');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should clamp to valid range', () => {
|
|
78
|
+
// Even with extreme values, should not crash
|
|
79
|
+
expect(() => brightnessToChar(-10)).not.toThrow();
|
|
80
|
+
expect(() => brightnessToChar(300)).not.toThrow();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('DEFAULT_CHARACTERS', () => {
|
|
85
|
+
it('should be standard ASCII art character set', () => {
|
|
86
|
+
expect(DEFAULT_CHARACTERS).toBe(' .:-=+*#%@');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should start with space', () => {
|
|
90
|
+
expect(DEFAULT_CHARACTERS[0]).toBe(' ');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should have 10 characters', () => {
|
|
94
|
+
expect(DEFAULT_CHARACTERS.length).toBe(10);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('DEFAULT_CONFIG', () => {
|
|
99
|
+
it('should have all required properties', () => {
|
|
100
|
+
expect(DEFAULT_CONFIG.characters).toBe(DEFAULT_CHARACTERS);
|
|
101
|
+
expect(DEFAULT_CONFIG.cellWidth).toBe(8);
|
|
102
|
+
expect(DEFAULT_CONFIG.cellHeight).toBe(12);
|
|
103
|
+
expect(DEFAULT_CONFIG.color).toBe('#ffffff');
|
|
104
|
+
expect(DEFAULT_CONFIG.backgroundColor).toBe('');
|
|
105
|
+
expect(DEFAULT_CONFIG.fontFamily).toBe('monospace');
|
|
106
|
+
expect(DEFAULT_CONFIG.animate).toBe(false);
|
|
107
|
+
expect(DEFAULT_CONFIG.fps).toBe(30);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('VERSION', () => {
|
|
112
|
+
it('should be a semver string', () => {
|
|
113
|
+
expect(VERSION).toMatch(/^\d+\.\d+\.\d+$/);
|
|
114
|
+
});
|
|
115
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Core Types
|
|
11
|
+
// =============================================================================
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
14
|
* Core configuration for ASCII rendering
|
|
11
15
|
*/
|
|
@@ -28,6 +32,32 @@ export interface GossamerConfig {
|
|
|
28
32
|
fps?: number;
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Preset configuration for effects
|
|
37
|
+
*/
|
|
38
|
+
export interface PresetConfig {
|
|
39
|
+
/** Preset display name */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Preset description */
|
|
42
|
+
description: string;
|
|
43
|
+
/** Character set */
|
|
44
|
+
characters: string;
|
|
45
|
+
/** Pattern type */
|
|
46
|
+
pattern: 'perlin' | 'waves' | 'static' | 'ripple' | 'fbm' | 'clouds' | 'plasma' | 'vortex' | 'matrix' | 'gradient' | 'diamond' | 'fractal';
|
|
47
|
+
/** Pattern frequency */
|
|
48
|
+
frequency: number;
|
|
49
|
+
/** Pattern amplitude */
|
|
50
|
+
amplitude: number;
|
|
51
|
+
/** Animation speed */
|
|
52
|
+
speed: number;
|
|
53
|
+
/** Default opacity */
|
|
54
|
+
opacity: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// =============================================================================
|
|
58
|
+
// Constants
|
|
59
|
+
// =============================================================================
|
|
60
|
+
|
|
31
61
|
/**
|
|
32
62
|
* Default character set ordered from light to dark
|
|
33
63
|
*/
|
|
@@ -47,6 +77,10 @@ export const DEFAULT_CONFIG: Required<GossamerConfig> = {
|
|
|
47
77
|
fps: 30,
|
|
48
78
|
};
|
|
49
79
|
|
|
80
|
+
// =============================================================================
|
|
81
|
+
// Core Functions
|
|
82
|
+
// =============================================================================
|
|
83
|
+
|
|
50
84
|
/**
|
|
51
85
|
* Calculate brightness from RGB values using luminance formula
|
|
52
86
|
* Uses the standard luminance coefficients: 0.21 R + 0.72 G + 0.07 B
|
|
@@ -66,16 +100,135 @@ export function brightnessToChar(
|
|
|
66
100
|
return characters[Math.min(index, characters.length - 1)];
|
|
67
101
|
}
|
|
68
102
|
|
|
103
|
+
// =============================================================================
|
|
104
|
+
// Module Exports
|
|
105
|
+
// =============================================================================
|
|
106
|
+
|
|
107
|
+
// Renderer
|
|
108
|
+
export { GossamerRenderer } from './renderer';
|
|
109
|
+
export type { RenderConfig } from './renderer';
|
|
110
|
+
|
|
111
|
+
// Patterns
|
|
112
|
+
export {
|
|
113
|
+
// Core noise functions
|
|
114
|
+
perlinNoise2D,
|
|
115
|
+
fbmNoise,
|
|
116
|
+
staticNoise,
|
|
117
|
+
seededNoise2D,
|
|
118
|
+
// Pattern generators
|
|
119
|
+
wavePattern,
|
|
120
|
+
ripplePattern,
|
|
121
|
+
cloudsPattern,
|
|
122
|
+
plasmaPattern,
|
|
123
|
+
vortexPattern,
|
|
124
|
+
matrixPattern,
|
|
125
|
+
gradientPattern,
|
|
126
|
+
diamondPattern,
|
|
127
|
+
fractalPattern,
|
|
128
|
+
// Grid generation (legacy API)
|
|
129
|
+
generateBrightnessGrid,
|
|
130
|
+
gridToImageData,
|
|
131
|
+
// Performance-optimized API
|
|
132
|
+
createBrightnessBuffer,
|
|
133
|
+
fillBrightnessBuffer,
|
|
134
|
+
getBufferValue,
|
|
135
|
+
// Config
|
|
136
|
+
DEFAULT_PATTERN_CONFIG,
|
|
137
|
+
} from './patterns';
|
|
138
|
+
export type { PatternConfig, PatternType, BrightnessBuffer } from './patterns';
|
|
139
|
+
|
|
140
|
+
// Characters
|
|
141
|
+
export {
|
|
142
|
+
CHARACTER_SETS,
|
|
143
|
+
getCharacterSet,
|
|
144
|
+
getCharacters,
|
|
145
|
+
getCharacterSetNames,
|
|
146
|
+
createCharacterSet,
|
|
147
|
+
validateCharacterSet,
|
|
148
|
+
invertCharacters,
|
|
149
|
+
} from './characters';
|
|
150
|
+
export type { CharacterSet } from './characters';
|
|
151
|
+
|
|
152
|
+
// Colors (Grove palette)
|
|
153
|
+
export {
|
|
154
|
+
GROVE_GREEN,
|
|
155
|
+
CREAM,
|
|
156
|
+
BARK,
|
|
157
|
+
STATUS,
|
|
158
|
+
GROVE_COLORS,
|
|
159
|
+
GLASS_SCHEMES,
|
|
160
|
+
getGroveColor,
|
|
161
|
+
getGlassScheme,
|
|
162
|
+
getGroveColorNames,
|
|
163
|
+
getGlassSchemeNames,
|
|
164
|
+
hexToRgba,
|
|
165
|
+
} from './colors';
|
|
166
|
+
export type { ColorDef, GroveColorName, GlassSchemeName } from './colors';
|
|
167
|
+
|
|
168
|
+
// Animation
|
|
169
|
+
export {
|
|
170
|
+
createAnimationLoop,
|
|
171
|
+
throttle,
|
|
172
|
+
debounce,
|
|
173
|
+
calculateFPS,
|
|
174
|
+
easings,
|
|
175
|
+
} from './animation';
|
|
176
|
+
export type { AnimationState, AnimationOptions, EasingFunction } from './animation';
|
|
177
|
+
|
|
178
|
+
// Canvas Utilities
|
|
179
|
+
export {
|
|
180
|
+
createCanvas,
|
|
181
|
+
getDevicePixelRatio,
|
|
182
|
+
resizeCanvasToContainer,
|
|
183
|
+
createOffscreenCanvas,
|
|
184
|
+
clearCanvas,
|
|
185
|
+
getImageData,
|
|
186
|
+
optimizeContext,
|
|
187
|
+
setupTextRendering,
|
|
188
|
+
measureTextWidth,
|
|
189
|
+
calculateCellSize,
|
|
190
|
+
setBlendMode,
|
|
191
|
+
} from './utils/canvas';
|
|
192
|
+
export type { CanvasOptions } from './utils/canvas';
|
|
193
|
+
|
|
194
|
+
// Image Utilities
|
|
195
|
+
export {
|
|
196
|
+
loadImage,
|
|
197
|
+
loadAndScaleImage,
|
|
198
|
+
imageToPixelData,
|
|
199
|
+
extractBrightness,
|
|
200
|
+
sampleImageCells,
|
|
201
|
+
rgbToHex,
|
|
202
|
+
hexToRgb,
|
|
203
|
+
adjustBrightness,
|
|
204
|
+
adjustContrast,
|
|
205
|
+
invertColors,
|
|
206
|
+
toGrayscale,
|
|
207
|
+
} from './utils/image';
|
|
208
|
+
export type { ImageLoadOptions } from './utils/image';
|
|
209
|
+
|
|
210
|
+
// Performance Utilities
|
|
211
|
+
export {
|
|
212
|
+
createVisibilityObserver,
|
|
213
|
+
createResizeObserver,
|
|
214
|
+
prefersReducedMotion,
|
|
215
|
+
onReducedMotionChange,
|
|
216
|
+
isLowPowerMode,
|
|
217
|
+
getRecommendedFPS,
|
|
218
|
+
createFPSCounter,
|
|
219
|
+
requestIdleCallback,
|
|
220
|
+
cancelIdleCallback,
|
|
221
|
+
isBrowser,
|
|
222
|
+
isCanvasSupported,
|
|
223
|
+
isOffscreenCanvasSupported,
|
|
224
|
+
} from './utils/performance';
|
|
225
|
+
export type { VisibilityCallback, PerformanceMetrics } from './utils/performance';
|
|
226
|
+
|
|
227
|
+
// =============================================================================
|
|
228
|
+
// Version
|
|
229
|
+
// =============================================================================
|
|
230
|
+
|
|
69
231
|
/**
|
|
70
|
-
* Gossamer
|
|
71
|
-
*
|
|
72
|
-
* Full implementation coming soon. This package will provide:
|
|
73
|
-
* - 2D Canvas ASCII rendering
|
|
74
|
-
* - Ambient pattern generation
|
|
75
|
-
* - Image-to-ASCII conversion
|
|
76
|
-
* - Animation loops
|
|
77
|
-
* - Framework adapters (Svelte, React, Vue)
|
|
78
|
-
*
|
|
79
|
-
* @see https://github.com/AutumnsGrove/Gossamer
|
|
232
|
+
* Gossamer version
|
|
80
233
|
*/
|
|
81
|
-
export const VERSION = '0.0
|
|
234
|
+
export const VERSION = '0.1.0';
|