textmode.js 0.8.0 → 0.8.1-beta.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 CHANGED
@@ -1,179 +1,179 @@
1
- # textmode.js (✿◠‿◠)
2
-
3
- <div align="center">
4
-
5
- <img alt="textmodejs_banner" src="https://github.com/user-attachments/assets/f03c2d74-7dc3-45cf-a0a5-043f9438231e" />
6
-
7
-
8
- | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![WebGL](https://img.shields.io/badge/WebGL1-990000?logo=webgl&logoColor=white)](https://www.khronos.org/webgl/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
9
- |:-------------|:-------------|:-------------|
10
-
11
- </div>
12
-
13
- textmode.js is a free, lightweight, and framework-agnostic creative-coding library for real‑time ASCII and textmode graphics in the browser. It combines a grid‑based API with a modern [`WebGL2`](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext) pipeline, multiple render targets, and aggressive instanced rendering to deliver smooth, high‑performance rendering.
14
-
15
- The library is designed to be easy to use and accessible to developers of all skill levels. Whether you're a seasoned developer or just starting out, `textmode.js` provides a simple and intuitive API that makes it easy to create stunning textmode art and animations.
16
-
17
- ## Features
18
-
19
- - Real‑time* ASCII/textmode rendering with a simple drawing API
20
- - Font system with runtime font loading and dynamic sizing *(supports TTF/OTF/WOFF)*
21
- - Dynamic layering system with blend modes and opacity for multi‑layered textmode scenes
22
- - Filter system with built-in filters and support for custom filter shaders
23
- - Load images and videos as sources and render them in customizable textmode styles
24
- - Author custom filter shaders in [`GLSL ES 3.00`](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf) for advanced effects
25
- - Flexible exporting: TXT, SVG, raster images *(PNG/JPG/WebP)*, animated GIFs, and video *(WebM)*
26
- - Animation loop control: `frameRate`, `loop`/`noLoop`, `redraw`, `frameCount`, etc.
27
- - Framework-agnostic: Use `textmode.js` with any canvas-based framework or library
28
- - Zero dependencies, written in TypeScript, with comprehensive type definitions
29
-
30
- > [!NOTE]
31
- > *Performance depends on the complexity of your scene and device capabilities. Consider authoring filter shaders for complex effects at low cost.
32
-
33
- ## Try it online first
34
-
35
- Before installing anything locally, you can try `textmode.js` directly in your browser using our dedicated web editor:
36
-
37
- 🌐 **[editor.textmode.art](https://editor.textmode.art)**
38
-
39
- The web editor is specifically designed for `textmode.js` and provides:
40
- - ✨ **Zero setup required** - Start coding immediately
41
- - 🚀 **Live preview** - See your creations in real-time
42
- - 💾 **Save & share** - Export your sketches and share with others
43
- - 📚 **Built-in examples** - Learn from interactive examples
44
- - 🔧 **Full API access** - All `textmode.js` features available
45
-
46
- The web editor is perfect for learning, prototyping, or creating quick experiments without any local setup!
47
-
48
- ## Installation
49
-
50
- ### Prerequisites
51
-
52
- To get started with `textmode.js`, you'll need:
53
- - A **modern web browser** with `WebGL2` support *(Chrome, Firefox, Safari, Edge, etc.)*
54
- - A [`<canvas>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) in your project *(optional, otherwise the library will create one for you)*
55
- - [Node.js 16+](https://nodejs.org/) and `npm` *(optional, for ESM installation)*
56
-
57
- > [!IMPORTANT]
58
- > `textmode.js` is currently fully dependent on `WebGL2`. Ensure your target browsers support it. You can check compatibility on [caniuse.com](https://caniuse.com/webgl2).
59
-
60
- ### Importing `textmode.js`
61
-
62
- #### UMD
63
-
64
- To use `textmode.js` in a UMD environment, download the latest `umd` build from the [**GitHub releases page**](https://github.com/humanbydefinition/textmode.js/releases/) or import it directly from a CDN like [**jsDelivr**](https://www.jsdelivr.com/package/npm/textmode.js). The library is distributed as a single JavaScript file, which you can include in your project by adding the following script tag to your HTML file:
65
-
66
- ```html
67
- <!-- index.html -->
68
- <!DOCTYPE html>
69
- <html>
70
- <head>
71
- <title>textmode.js sketch</title>
72
-
73
- <!-- Standard bundle (with embedded UrsaFont) -->
74
- <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
75
- </head>
76
- <body>
77
- <script src="sketch.js"></script>
78
- </body>
79
- </html>
80
- ```
81
-
82
- ```javascript
83
- // sketch.js
84
- const t = textmode.create({
85
- width: window.innerWidth,
86
- height: window.innerHeight,
87
- fontSize: 16,
88
- frameRate: 60
89
- });
90
-
91
- t.setup(() => {
92
- // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
93
- });
94
-
95
- t.draw(() => {
96
- t.background(32); // Dark gray background
97
-
98
- t.char('A');
99
- t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
100
- t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
101
-
102
- // ...add your drawing code here!
103
- });
104
-
105
- t.windowResized(() => {
106
- t.resizeCanvas(window.innerWidth, window.innerHeight);
107
- });
108
- ```
109
-
110
- #### ESM
111
-
112
- To use `textmode.js` in an ESM environment, you can install it via `npm`:
113
-
114
- ```bash
115
- npm install textmode.js
116
- ```
117
-
118
- Then, you can import it in your JavaScript or TypeScript files:
119
-
120
- ```html
121
- <!-- index.html -->
122
- <!DOCTYPE html>
123
- <html lang="en">
124
- <head>
125
- <meta charset="utf-8">
126
- <title>textmode.js sketch</title>
127
- </head>
128
- <body>
129
- <script type="module" src="./sketch.js"></script>
130
- </body>
131
- </html>
132
- ```
133
-
134
- ```javascript
135
- // sketch.js
136
- // Standard bundle (with embedded UrsaFont)
137
- import { textmode } from 'textmode.js';
138
-
139
- const t = textmode.create({
140
- width: window.innerWidth,
141
- height: window.innerHeight,
142
- fontSize: 16,
143
- frameRate: 60
144
- });
145
-
146
- t.setup(() => {
147
- // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
148
- });
149
-
150
- t.draw(() => {
151
- t.background(32); // Dark gray background
152
-
153
- t.char('A');
154
- t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
155
- t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
156
-
157
- // ...add your drawing code here!
158
- });
159
-
160
- t.windowResized(() => {
161
- t.resizeCanvas(window.innerWidth, window.innerHeight);
162
- });
163
- ```
164
-
165
- ## Next steps
166
-
167
- Now that you have `textmode.js` set up, you can start creating your textmode art projects! Going forward, here are some resources to help you get the most out of the library:
168
-
169
- 📚 **[Visit the Official Documentation](https://code.textmode.art/)** for detailed guides, interactive examples, complete API reference, tips and tricks, and much more to unlock the full potential of `textmode.js` in your creative coding projects.
170
-
171
- 🎨 **[Try the Web Editor](https://editor.textmode.art)** to experiment with `textmode.js` without setting up a local environment.
172
-
173
- ## Acknowledgements
174
-
175
- `textmode.js` uses a custom-made TypeScript rewrite and minified version of [`Typr.js`](https://github.com/photopea/Typr.js) by [**Photopea**](https://github.com/photopea) for font loading and parsing, containing only the necessary components for our use case. `Typr.js` is licensed under the [**MIT License**](https://github.com/photopea/Typr.js/blob/main/LICENSE).
176
-
177
-
178
- `textmode.js` ships with [`UrsaFont`](https://ursafrank.itch.io/ursafont) as the default font, created by [**UrsaFrank**](https://ursafrank.itch.io/). This font is available under the [**CC0 (Creative Commons Zero) license**](https://creativecommons.org/publicdomain/zero/1.0/).
179
-
1
+ # textmode.js (✿◠‿◠)
2
+
3
+ <div align="center">
4
+
5
+ <img alt="textmodejs_banner" src="https://github.com/user-attachments/assets/f03c2d74-7dc3-45cf-a0a5-043f9438231e" />
6
+
7
+
8
+ | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![WebGL](https://img.shields.io/badge/WebGL1-990000?logo=webgl&logoColor=white)](https://www.khronos.org/webgl/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![Github-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
9
+ |:-------------|:-------------|:-------------|
10
+
11
+ </div>
12
+
13
+ textmode.js is a free, lightweight, and framework-agnostic creative-coding library for real‑time ASCII and textmode graphics in the browser. It combines a grid‑based API with a modern [`WebGL2`](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext) pipeline, multiple render targets, and aggressive instanced rendering to deliver smooth, high‑performance rendering.
14
+
15
+ The library is designed to be easy to use and accessible to developers of all skill levels. Whether you're a seasoned developer or just starting out, `textmode.js` provides a simple and intuitive API that makes it easy to create stunning textmode art and animations.
16
+
17
+ ## Features
18
+
19
+ - Real‑time* ASCII/textmode rendering with a simple drawing API
20
+ - Font system with runtime font loading and dynamic sizing *(supports TTF/OTF/WOFF)*
21
+ - Dynamic layering system with blend modes and opacity for multi‑layered textmode scenes
22
+ - Filter system with built-in filters and support for custom filter shaders
23
+ - Load images and videos as sources and render them in customizable textmode styles
24
+ - Author custom filter shaders in [`GLSL ES 3.00`](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf) for advanced effects
25
+ - Flexible exporting: TXT, SVG, raster images *(PNG/JPG/WebP)*, animated GIFs, and video *(WebM)*
26
+ - Animation loop control: `frameRate`, `loop`/`noLoop`, `redraw`, `frameCount`, etc.
27
+ - Framework-agnostic: Use `textmode.js` with any canvas-based framework or library
28
+ - Zero dependencies, written in TypeScript, with comprehensive type definitions
29
+
30
+ > [!NOTE]
31
+ > *Performance depends on the complexity of your scene and device capabilities. Consider authoring filter shaders for complex effects at low cost.
32
+
33
+ ## Try it online first
34
+
35
+ Before installing anything locally, you can try `textmode.js` directly in your browser using our dedicated web editor:
36
+
37
+ 🌐 **[editor.textmode.art](https://editor.textmode.art)**
38
+
39
+ The web editor is specifically designed for `textmode.js` and provides:
40
+ - ✨ **Zero setup required** - Start coding immediately
41
+ - 🚀 **Live preview** - See your creations in real-time
42
+ - 💾 **Save & share** - Export your sketches and share with others
43
+ - 📚 **Built-in examples** - Learn from interactive examples
44
+ - 🔧 **Full API access** - All `textmode.js` features available
45
+
46
+ The web editor is perfect for learning, prototyping, or creating quick experiments without any local setup!
47
+
48
+ ## Installation
49
+
50
+ ### Prerequisites
51
+
52
+ To get started with `textmode.js`, you'll need:
53
+ - A **modern web browser** with `WebGL2` support *(Chrome, Firefox, Safari, Edge, etc.)*
54
+ - A [`<canvas>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas) in your project *(optional, otherwise the library will create one for you)*
55
+ - [Node.js 16+](https://nodejs.org/) and `npm` *(optional, for ESM installation)*
56
+
57
+ > [!IMPORTANT]
58
+ > `textmode.js` is currently fully dependent on `WebGL2`. Ensure your target browsers support it. You can check compatibility on [caniuse.com](https://caniuse.com/webgl2).
59
+
60
+ ### Importing `textmode.js`
61
+
62
+ #### UMD
63
+
64
+ To use `textmode.js` in a UMD environment, download the latest `umd` build from the [**GitHub releases page**](https://github.com/humanbydefinition/textmode.js/releases/) or import it directly from a CDN like [**jsDelivr**](https://www.jsdelivr.com/package/npm/textmode.js). The library is distributed as a single JavaScript file, which you can include in your project by adding the following script tag to your HTML file:
65
+
66
+ ```html
67
+ <!-- index.html -->
68
+ <!DOCTYPE html>
69
+ <html>
70
+ <head>
71
+ <title>textmode.js sketch</title>
72
+
73
+ <!-- Standard bundle (with embedded UrsaFont) -->
74
+ <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
75
+ </head>
76
+ <body>
77
+ <script src="sketch.js"></script>
78
+ </body>
79
+ </html>
80
+ ```
81
+
82
+ ```javascript
83
+ // sketch.js
84
+ const t = textmode.create({
85
+ width: window.innerWidth,
86
+ height: window.innerHeight,
87
+ fontSize: 16,
88
+ frameRate: 60
89
+ });
90
+
91
+ t.setup(() => {
92
+ // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
93
+ });
94
+
95
+ t.draw(() => {
96
+ t.background(32); // Dark gray background
97
+
98
+ t.char('A');
99
+ t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
100
+ t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
101
+
102
+ // ...add your drawing code here!
103
+ });
104
+
105
+ t.windowResized(() => {
106
+ t.resizeCanvas(window.innerWidth, window.innerHeight);
107
+ });
108
+ ```
109
+
110
+ #### ESM
111
+
112
+ To use `textmode.js` in an ESM environment, you can install it via `npm`:
113
+
114
+ ```bash
115
+ npm install textmode.js
116
+ ```
117
+
118
+ Then, you can import it in your JavaScript or TypeScript files:
119
+
120
+ ```html
121
+ <!-- index.html -->
122
+ <!DOCTYPE html>
123
+ <html lang="en">
124
+ <head>
125
+ <meta charset="utf-8">
126
+ <title>textmode.js sketch</title>
127
+ </head>
128
+ <body>
129
+ <script type="module" src="./sketch.js"></script>
130
+ </body>
131
+ </html>
132
+ ```
133
+
134
+ ```javascript
135
+ // sketch.js
136
+ // Standard bundle (with embedded UrsaFont)
137
+ import { textmode } from 'textmode.js';
138
+
139
+ const t = textmode.create({
140
+ width: window.innerWidth,
141
+ height: window.innerHeight,
142
+ fontSize: 16,
143
+ frameRate: 60
144
+ });
145
+
146
+ t.setup(() => {
147
+ // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
148
+ });
149
+
150
+ t.draw(() => {
151
+ t.background(32); // Dark gray background
152
+
153
+ t.char('A');
154
+ t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
155
+ t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
156
+
157
+ // ...add your drawing code here!
158
+ });
159
+
160
+ t.windowResized(() => {
161
+ t.resizeCanvas(window.innerWidth, window.innerHeight);
162
+ });
163
+ ```
164
+
165
+ ## Next steps
166
+
167
+ Now that you have `textmode.js` set up, you can start creating your textmode art projects! Going forward, here are some resources to help you get the most out of the library:
168
+
169
+ 📚 **[Visit the Official Documentation](https://code.textmode.art/)** for detailed guides, interactive examples, complete API reference, tips and tricks, and much more to unlock the full potential of `textmode.js` in your creative coding projects.
170
+
171
+ 🎨 **[Try the Web Editor](https://editor.textmode.art)** to experiment with `textmode.js` without setting up a local environment.
172
+
173
+ ## Acknowledgements
174
+
175
+ `textmode.js` uses a custom-made TypeScript rewrite and minified version of [`Typr.js`](https://github.com/photopea/Typr.js) by [**Photopea**](https://github.com/photopea) for font loading and parsing, containing only the necessary components for our use case. `Typr.js` is licensed under the [**MIT License**](https://github.com/photopea/Typr.js/blob/main/LICENSE).
176
+
177
+
178
+ `textmode.js` ships with [`UrsaFont`](https://ursafrank.itch.io/ursafont) as the default font, created by [**UrsaFrank**](https://ursafrank.itch.io/). This font is available under the [**CC0 (Creative Commons Zero) license**](https://creativecommons.org/publicdomain/zero/1.0/).
179
+