@autumnsgrove/gossamer 0.0.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/README.md +39 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
- package/src/index.ts +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# gossamer (core)
|
|
2
|
+
|
|
3
|
+
Core rendering engine for Gossamer ASCII visual effects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add gossamer
|
|
9
|
+
# or
|
|
10
|
+
npm install gossamer
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { GossamerRenderer, generatePatternData } from 'gossamer';
|
|
17
|
+
|
|
18
|
+
const canvas = document.getElementById('myCanvas') as HTMLCanvasElement;
|
|
19
|
+
const renderer = new GossamerRenderer(canvas, {
|
|
20
|
+
characters: ' ·∙•◦○◉●',
|
|
21
|
+
cellSize: 12,
|
|
22
|
+
color: '#22c55e'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Render animated clouds
|
|
26
|
+
renderer.startAnimation((time) => {
|
|
27
|
+
return generatePatternData(
|
|
28
|
+
canvas.width,
|
|
29
|
+
canvas.height,
|
|
30
|
+
'perlin',
|
|
31
|
+
time * 0.001,
|
|
32
|
+
{ frequency: 0.05, amplitude: 1.0, speed: 0.5 }
|
|
33
|
+
);
|
|
34
|
+
}, 30);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
See the [main repository](https://github.com/AutumnsGrove/Gossamer) for full documentation.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gossamer - ASCII Visual Effects Library
|
|
3
|
+
*
|
|
4
|
+
* Threads of light. Delicate textures woven through your space.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Core configuration for ASCII rendering
|
|
10
|
+
*/
|
|
11
|
+
export interface GossamerConfig {
|
|
12
|
+
/** Character set for ASCII rendering (light to dark) */
|
|
13
|
+
characters?: string;
|
|
14
|
+
/** Cell width in pixels */
|
|
15
|
+
cellWidth?: number;
|
|
16
|
+
/** Cell height in pixels */
|
|
17
|
+
cellHeight?: number;
|
|
18
|
+
/** Foreground color */
|
|
19
|
+
color?: string;
|
|
20
|
+
/** Background color (transparent if not set) */
|
|
21
|
+
backgroundColor?: string;
|
|
22
|
+
/** Font family for ASCII characters */
|
|
23
|
+
fontFamily?: string;
|
|
24
|
+
/** Enable animation loop */
|
|
25
|
+
animate?: boolean;
|
|
26
|
+
/** Target FPS for animation */
|
|
27
|
+
fps?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Default character set ordered from light to dark
|
|
31
|
+
*/
|
|
32
|
+
export declare const DEFAULT_CHARACTERS = " .:-=+*#%@";
|
|
33
|
+
/**
|
|
34
|
+
* Default configuration values
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_CONFIG: Required<GossamerConfig>;
|
|
37
|
+
/**
|
|
38
|
+
* Calculate brightness from RGB values using luminance formula
|
|
39
|
+
* Uses the standard luminance coefficients: 0.21 R + 0.72 G + 0.07 B
|
|
40
|
+
*/
|
|
41
|
+
export declare function calculateBrightness(r: number, g: number, b: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Map a brightness value (0-255) to an ASCII character
|
|
44
|
+
*/
|
|
45
|
+
export declare function brightnessToChar(brightness: number, characters?: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Gossamer v0.0.1 - Placeholder release
|
|
48
|
+
*
|
|
49
|
+
* Full implementation coming soon. This package will provide:
|
|
50
|
+
* - 2D Canvas ASCII rendering
|
|
51
|
+
* - Ambient pattern generation
|
|
52
|
+
* - Image-to-ASCII conversion
|
|
53
|
+
* - Animation loops
|
|
54
|
+
* - Framework adapters (Svelte, React, Vue)
|
|
55
|
+
*
|
|
56
|
+
* @see https://github.com/AutumnsGrove/Gossamer
|
|
57
|
+
*/
|
|
58
|
+
export declare const VERSION = "0.0.1";
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+BAA+B;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,cAAc,CASnD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAA2B,GACtC,MAAM,CAGR;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const DEFAULT_CHARACTERS = " .:-=+*#%@";
|
|
2
|
+
const DEFAULT_CONFIG = {
|
|
3
|
+
characters: DEFAULT_CHARACTERS,
|
|
4
|
+
cellWidth: 8,
|
|
5
|
+
cellHeight: 12,
|
|
6
|
+
color: "#ffffff",
|
|
7
|
+
backgroundColor: "",
|
|
8
|
+
fontFamily: "monospace",
|
|
9
|
+
animate: false,
|
|
10
|
+
fps: 30
|
|
11
|
+
};
|
|
12
|
+
function calculateBrightness(r, g, b) {
|
|
13
|
+
return 0.21 * r + 0.72 * g + 0.07 * b;
|
|
14
|
+
}
|
|
15
|
+
function brightnessToChar(brightness, characters = DEFAULT_CHARACTERS) {
|
|
16
|
+
const index = Math.floor(brightness / 255 * (characters.length - 1));
|
|
17
|
+
return characters[Math.min(index, characters.length - 1)];
|
|
18
|
+
}
|
|
19
|
+
const VERSION = "0.0.1";
|
|
20
|
+
export {
|
|
21
|
+
DEFAULT_CHARACTERS,
|
|
22
|
+
DEFAULT_CONFIG,
|
|
23
|
+
VERSION,
|
|
24
|
+
brightnessToChar,
|
|
25
|
+
calculateBrightness
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Gossamer - ASCII Visual Effects Library\n *\n * Threads of light. Delicate textures woven through your space.\n *\n * @packageDocumentation\n */\n\n/**\n * Core configuration for ASCII rendering\n */\nexport interface GossamerConfig {\n /** Character set for ASCII rendering (light to dark) */\n characters?: string;\n /** Cell width in pixels */\n cellWidth?: number;\n /** Cell height in pixels */\n cellHeight?: number;\n /** Foreground color */\n color?: string;\n /** Background color (transparent if not set) */\n backgroundColor?: string;\n /** Font family for ASCII characters */\n fontFamily?: string;\n /** Enable animation loop */\n animate?: boolean;\n /** Target FPS for animation */\n fps?: number;\n}\n\n/**\n * Default character set ordered from light to dark\n */\nexport const DEFAULT_CHARACTERS = ' .:-=+*#%@';\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONFIG: Required<GossamerConfig> = {\n characters: DEFAULT_CHARACTERS,\n cellWidth: 8,\n cellHeight: 12,\n color: '#ffffff',\n backgroundColor: '',\n fontFamily: 'monospace',\n animate: false,\n fps: 30,\n};\n\n/**\n * Calculate brightness from RGB values using luminance formula\n * Uses the standard luminance coefficients: 0.21 R + 0.72 G + 0.07 B\n */\nexport function calculateBrightness(r: number, g: number, b: number): number {\n return 0.21 * r + 0.72 * g + 0.07 * b;\n}\n\n/**\n * Map a brightness value (0-255) to an ASCII character\n */\nexport function brightnessToChar(\n brightness: number,\n characters: string = DEFAULT_CHARACTERS\n): string {\n const index = Math.floor((brightness / 255) * (characters.length - 1));\n return characters[Math.min(index, characters.length - 1)];\n}\n\n/**\n * Gossamer v0.0.1 - Placeholder release\n *\n * Full implementation coming soon. This package will provide:\n * - 2D Canvas ASCII rendering\n * - Ambient pattern generation\n * - Image-to-ASCII conversion\n * - Animation loops\n * - Framework adapters (Svelte, React, Vue)\n *\n * @see https://github.com/AutumnsGrove/Gossamer\n */\nexport const VERSION = '0.0.1';\n"],"names":[],"mappings":"AAiCO,MAAM,qBAAqB;AAK3B,MAAM,iBAA2C;AAAA,EACtD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,KAAK;AACP;AAMO,SAAS,oBAAoB,GAAW,GAAW,GAAmB;AAC3E,SAAO,OAAO,IAAI,OAAO,IAAI,OAAO;AACtC;AAKO,SAAS,iBACd,YACA,aAAqB,oBACb;AACR,QAAM,QAAQ,KAAK,MAAO,aAAa,OAAQ,WAAW,SAAS,EAAE;AACrE,SAAO,WAAW,KAAK,IAAI,OAAO,WAAW,SAAS,CAAC,CAAC;AAC1D;AAcO,MAAM,UAAU;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@autumnsgrove/gossamer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "ASCII visual effects library - Threads of light for your web applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite build --watch",
|
|
21
|
+
"build": "tsc && vite build",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"test:coverage": "vitest run --coverage",
|
|
25
|
+
"clean": "rm -rf dist"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"ascii",
|
|
29
|
+
"ascii-art",
|
|
30
|
+
"canvas",
|
|
31
|
+
"visual-effects",
|
|
32
|
+
"animation",
|
|
33
|
+
"graphics",
|
|
34
|
+
"text-art",
|
|
35
|
+
"ambient",
|
|
36
|
+
"texture",
|
|
37
|
+
"pattern"
|
|
38
|
+
],
|
|
39
|
+
"author": "AutumnsGrove",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"homepage": "https://github.com/AutumnsGrove/Gossamer#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/AutumnsGrove/Gossamer/issues"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/AutumnsGrove/Gossamer.git",
|
|
48
|
+
"directory": "packages/core"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.10.0",
|
|
52
|
+
"typescript": "^5.3.0",
|
|
53
|
+
"vite": "^5.0.0",
|
|
54
|
+
"vite-plugin-dts": "^3.7.0",
|
|
55
|
+
"vitest": "^1.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gossamer - ASCII Visual Effects Library
|
|
3
|
+
*
|
|
4
|
+
* Threads of light. Delicate textures woven through your space.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Core configuration for ASCII rendering
|
|
11
|
+
*/
|
|
12
|
+
export interface GossamerConfig {
|
|
13
|
+
/** Character set for ASCII rendering (light to dark) */
|
|
14
|
+
characters?: string;
|
|
15
|
+
/** Cell width in pixels */
|
|
16
|
+
cellWidth?: number;
|
|
17
|
+
/** Cell height in pixels */
|
|
18
|
+
cellHeight?: number;
|
|
19
|
+
/** Foreground color */
|
|
20
|
+
color?: string;
|
|
21
|
+
/** Background color (transparent if not set) */
|
|
22
|
+
backgroundColor?: string;
|
|
23
|
+
/** Font family for ASCII characters */
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
/** Enable animation loop */
|
|
26
|
+
animate?: boolean;
|
|
27
|
+
/** Target FPS for animation */
|
|
28
|
+
fps?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default character set ordered from light to dark
|
|
33
|
+
*/
|
|
34
|
+
export const DEFAULT_CHARACTERS = ' .:-=+*#%@';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Default configuration values
|
|
38
|
+
*/
|
|
39
|
+
export const DEFAULT_CONFIG: Required<GossamerConfig> = {
|
|
40
|
+
characters: DEFAULT_CHARACTERS,
|
|
41
|
+
cellWidth: 8,
|
|
42
|
+
cellHeight: 12,
|
|
43
|
+
color: '#ffffff',
|
|
44
|
+
backgroundColor: '',
|
|
45
|
+
fontFamily: 'monospace',
|
|
46
|
+
animate: false,
|
|
47
|
+
fps: 30,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Calculate brightness from RGB values using luminance formula
|
|
52
|
+
* Uses the standard luminance coefficients: 0.21 R + 0.72 G + 0.07 B
|
|
53
|
+
*/
|
|
54
|
+
export function calculateBrightness(r: number, g: number, b: number): number {
|
|
55
|
+
return 0.21 * r + 0.72 * g + 0.07 * b;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Map a brightness value (0-255) to an ASCII character
|
|
60
|
+
*/
|
|
61
|
+
export function brightnessToChar(
|
|
62
|
+
brightness: number,
|
|
63
|
+
characters: string = DEFAULT_CHARACTERS
|
|
64
|
+
): string {
|
|
65
|
+
const index = Math.floor((brightness / 255) * (characters.length - 1));
|
|
66
|
+
return characters[Math.min(index, characters.length - 1)];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Gossamer v0.0.1 - Placeholder release
|
|
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
|
|
80
|
+
*/
|
|
81
|
+
export const VERSION = '0.0.1';
|