textmode.js 0.9.0-beta.2 → 0.9.0-beta.4

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 (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +180 -179
  3. package/dist/textmode.esm.js +2562 -2779
  4. package/dist/textmode.umd.js +16 -18
  5. package/package.json +151 -107
  6. package/dist/types/Textmode.d.ts +0 -62
  7. package/dist/types/errors/Error.d.ts +0 -11
  8. package/dist/types/errors/ErrorHandler.d.ts +0 -77
  9. package/dist/types/errors/index.d.ts +0 -2
  10. package/dist/types/exports/conversion.d.ts +0 -1
  11. package/dist/types/exports/filters.d.ts +0 -1
  12. package/dist/types/exports/input.d.ts +0 -1
  13. package/dist/types/exports/layering.d.ts +0 -1
  14. package/dist/types/exports/loadables.d.ts +0 -1
  15. package/dist/types/exports/loading.d.ts +0 -1
  16. package/dist/types/exports/plugins.d.ts +0 -1
  17. package/dist/types/index.d.ts +0 -83
  18. package/dist/types/rendering/index.d.ts +0 -3
  19. package/dist/types/rendering/webgl/batching/DrawQueue.d.ts +0 -89
  20. package/dist/types/rendering/webgl/batching/GeometryAttributeCache.d.ts +0 -15
  21. package/dist/types/rendering/webgl/batching/InstanceAttributeBinder.d.ts +0 -87
  22. package/dist/types/rendering/webgl/batching/InstanceBatch.d.ts +0 -82
  23. package/dist/types/rendering/webgl/batching/InstanceBuffer.d.ts +0 -78
  24. package/dist/types/rendering/webgl/batching/InstanceData.d.ts +0 -60
  25. package/dist/types/rendering/webgl/batching/InstanceWriter.d.ts +0 -70
  26. package/dist/types/rendering/webgl/core/Framebuffer.d.ts +0 -93
  27. package/dist/types/rendering/webgl/core/Renderer.d.ts +0 -75
  28. package/dist/types/rendering/webgl/core/Shader.d.ts +0 -65
  29. package/dist/types/rendering/webgl/core/interfaces/IFramebuffer.d.ts +0 -96
  30. package/dist/types/rendering/webgl/core/interfaces/IRenderer.d.ts +0 -210
  31. package/dist/types/rendering/webgl/geometries/2d/Arc.d.ts +0 -17
  32. package/dist/types/rendering/webgl/geometries/2d/BezierCurve.d.ts +0 -23
  33. package/dist/types/rendering/webgl/geometries/2d/Ellipse.d.ts +0 -21
  34. package/dist/types/rendering/webgl/geometries/2d/Line.d.ts +0 -21
  35. package/dist/types/rendering/webgl/geometries/2d/Rectangle.d.ts +0 -21
  36. package/dist/types/rendering/webgl/geometries/2d/Triangle.d.ts +0 -21
  37. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +0 -53
  38. package/dist/types/rendering/webgl/geometries/immediate/ImmediateQuad.d.ts +0 -33
  39. package/dist/types/rendering/webgl/geometries/index.d.ts +0 -6
  40. package/dist/types/rendering/webgl/geometries/utils/GeometryDescriptors.d.ts +0 -31
  41. package/dist/types/rendering/webgl/geometries/utils/GeometryGenerator.d.ts +0 -16
  42. package/dist/types/rendering/webgl/index.d.ts +0 -19
  43. package/dist/types/rendering/webgl/materials/Material.d.ts +0 -26
  44. package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +0 -62
  45. package/dist/types/rendering/webgl/materials/index.d.ts +0 -2
  46. package/dist/types/rendering/webgl/pipeline/MaterialBatchPipeline.d.ts +0 -63
  47. package/dist/types/rendering/webgl/pipeline/index.d.ts +0 -7
  48. package/dist/types/rendering/webgl/state/RenderState.d.ts +0 -143
  49. package/dist/types/rendering/webgl/types/DrawCommand.d.ts +0 -20
  50. package/dist/types/rendering/webgl/types/GeometryTypes.d.ts +0 -144
  51. package/dist/types/rendering/webgl/types/RenderTypes.d.ts +0 -14
  52. package/dist/types/rendering/webgl/utils/GLUtils.d.ts +0 -45
  53. package/dist/types/rendering/webgl/utils/ViewportCache.d.ts +0 -4
  54. package/dist/types/rendering/webgl/utils/hash.d.ts +0 -102
  55. package/dist/types/textmode/AnimationController.d.ts +0 -100
  56. package/dist/types/textmode/Canvas.d.ts +0 -53
  57. package/dist/types/textmode/Grid.d.ts +0 -92
  58. package/dist/types/textmode/TextmodeColor.d.ts +0 -61
  59. package/dist/types/textmode/Textmodifier.d.ts +0 -103
  60. package/dist/types/textmode/conversion/ConversionManager.d.ts +0 -73
  61. package/dist/types/textmode/conversion/ConversionRegistry.d.ts +0 -92
  62. package/dist/types/textmode/conversion/index.d.ts +0 -3
  63. package/dist/types/textmode/conversion/strategies/brightness.d.ts +0 -2
  64. package/dist/types/textmode/filters/FilterManager.d.ts +0 -128
  65. package/dist/types/textmode/filters/FilterRegistry.d.ts +0 -75
  66. package/dist/types/textmode/filters/index.d.ts +0 -3
  67. package/dist/types/textmode/filters/types.d.ts +0 -77
  68. package/dist/types/textmode/interfaces/ITextmodifier.d.ts +0 -441
  69. package/dist/types/textmode/interfaces/index.d.ts +0 -1
  70. package/dist/types/textmode/layers/Camera3D.d.ts +0 -205
  71. package/dist/types/textmode/layers/Layer2DCompositor.d.ts +0 -79
  72. package/dist/types/textmode/layers/Layer3DCompositor.d.ts +0 -152
  73. package/dist/types/textmode/layers/LayerManager.d.ts +0 -151
  74. package/dist/types/textmode/layers/TextmodeLayer.d.ts +0 -106
  75. package/dist/types/textmode/layers/index.d.ts +0 -8
  76. package/dist/types/textmode/layers/interfaces/ILayerManager.d.ts +0 -102
  77. package/dist/types/textmode/layers/interfaces/ITextmodeLayer.d.ts +0 -427
  78. package/dist/types/textmode/layers/types.d.ts +0 -78
  79. package/dist/types/textmode/loadables/ITextmodeSource.d.ts +0 -123
  80. package/dist/types/textmode/loadables/TextmodeImage.d.ts +0 -46
  81. package/dist/types/textmode/loadables/TextmodeSource.d.ts +0 -67
  82. package/dist/types/textmode/loadables/font/CharacterColorMapper.d.ts +0 -34
  83. package/dist/types/textmode/loadables/font/CharacterExtractor.d.ts +0 -25
  84. package/dist/types/textmode/loadables/font/MetricsCalculator.d.ts +0 -23
  85. package/dist/types/textmode/loadables/font/TextmodeFont.d.ts +0 -106
  86. package/dist/types/textmode/loadables/font/TextureAtlas.d.ts +0 -56
  87. package/dist/types/textmode/loadables/font/index.d.ts +0 -8
  88. package/dist/types/textmode/loadables/font/types.d.ts +0 -44
  89. package/dist/types/textmode/loadables/font/typr/Typr.d.ts +0 -20
  90. package/dist/types/textmode/loadables/font/typr/types.d.ts +0 -238
  91. package/dist/types/textmode/loadables/font/utils/FontTableReader.d.ts +0 -40
  92. package/dist/types/textmode/loadables/font/utils/index.d.ts +0 -7
  93. package/dist/types/textmode/loadables/index.d.ts +0 -4
  94. package/dist/types/textmode/loadables/video/ITextmodeVideo.d.ts +0 -75
  95. package/dist/types/textmode/loadables/video/TextmodeVideo.d.ts +0 -93
  96. package/dist/types/textmode/loading/LoadingPhase.d.ts +0 -28
  97. package/dist/types/textmode/loading/LoadingPhaseTracker.d.ts +0 -20
  98. package/dist/types/textmode/loading/LoadingScreenManager.d.ts +0 -209
  99. package/dist/types/textmode/loading/LoadingScreenState.d.ts +0 -22
  100. package/dist/types/textmode/loading/LoadingScreenTheme.d.ts +0 -26
  101. package/dist/types/textmode/loading/LoadingScreenTransition.d.ts +0 -17
  102. package/dist/types/textmode/loading/index.d.ts +0 -7
  103. package/dist/types/textmode/loading/templates/SpinnerTemplate.d.ts +0 -2
  104. package/dist/types/textmode/loading/templates/index.d.ts +0 -1
  105. package/dist/types/textmode/loading/types.d.ts +0 -255
  106. package/dist/types/textmode/managers/KeyboardManager.d.ts +0 -124
  107. package/dist/types/textmode/managers/MouseManager.d.ts +0 -163
  108. package/dist/types/textmode/managers/PluginManager.d.ts +0 -226
  109. package/dist/types/textmode/managers/TouchManager.d.ts +0 -240
  110. package/dist/types/textmode/managers/index.d.ts +0 -12
  111. package/dist/types/textmode/mixins/AnimationMixin.d.ts +0 -8
  112. package/dist/types/textmode/mixins/KeyboardMixin.d.ts +0 -13
  113. package/dist/types/textmode/mixins/MouseMixin.d.ts +0 -10
  114. package/dist/types/textmode/mixins/RenderingMixin.d.ts +0 -8
  115. package/dist/types/textmode/mixins/TextmodifierMixin.d.ts +0 -19
  116. package/dist/types/textmode/mixins/TouchMixin.d.ts +0 -6
  117. package/dist/types/textmode/mixins/index.d.ts +0 -9
  118. package/dist/types/textmode/mixins/interfaces/IAnimationMixin.d.ts +0 -300
  119. package/dist/types/textmode/mixins/interfaces/IKeyboardMixin.d.ts +0 -234
  120. package/dist/types/textmode/mixins/interfaces/IMouseMixin.d.ts +0 -448
  121. package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +0 -1151
  122. package/dist/types/textmode/mixins/interfaces/ITouchMixin.d.ts +0 -186
  123. package/dist/types/textmode/types.d.ts +0 -46
  124. package/dist/types/textmode/utils/cssColor.d.ts +0 -8
  125. package/dist/types/utils/TextmodeCollection.d.ts +0 -262
  126. package/dist/types/utils/array.d.ts +0 -34
  127. package/dist/types/utils/color.d.ts +0 -1
  128. package/dist/types/utils/mat3.d.ts +0 -149
  129. package/dist/types/utils/math.d.ts +0 -95
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 humanbydefinition
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,179 +1,180 @@
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
+ | [![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) |
8
+ |:-------------|:-------------|:-------------|
9
+
10
+ </div>
11
+
12
+ 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.
13
+
14
+ 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.
15
+
16
+ ## Features
17
+
18
+ - Real‑time* ASCII/textmode rendering with a simple drawing API
19
+ - Font system with runtime font loading and dynamic sizing *(supports TTF/OTF/WOFF)*
20
+ - Dynamic layering system with blend modes and opacity for multi‑layered textmode scenes
21
+ - Filter system with built-in filters and support for custom filter shaders
22
+ - Load images and videos as sources and render them in customizable textmode styles
23
+ - 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
24
+ - Flexible exporting: TXT, SVG, raster images *(PNG/JPG/WebP)*, animated GIFs, and video *(WebM)*
25
+ - Animation loop control: `frameRate`, `loop`/`noLoop`, `redraw`, `frameCount`, etc.
26
+ - Framework-agnostic: Use `textmode.js` with any canvas-based framework or library
27
+ - Zero dependencies, written in TypeScript, with comprehensive type definitions
28
+
29
+ > [!NOTE]
30
+ > *Performance depends on the complexity of your scene and device capabilities. Consider authoring filter shaders for complex effects at low cost.
31
+
32
+ ## Try it online first
33
+
34
+ Before installing anything locally, you can try `textmode.js` directly in your browser using our dedicated web editor:
35
+
36
+ 🌐 **[editor.textmode.art](https://editor.textmode.art)**
37
+
38
+ The web editor is specifically designed for `textmode.js` and provides:
39
+
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
+
54
+ - A **modern web browser** with `WebGL2` support *(Chrome, Firefox, Safari, Edge, etc.)*
55
+ - 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)*
56
+ - [Node.js 16+](https://nodejs.org/) and `npm` *(optional, for ESM installation)*
57
+
58
+ > [!IMPORTANT]
59
+ > `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).
60
+
61
+ ### Importing `textmode.js`
62
+
63
+ #### UMD
64
+
65
+ 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:
66
+
67
+ ```html
68
+ <!-- index.html -->
69
+ <!DOCTYPE html>
70
+ <html>
71
+ <head>
72
+ <title>textmode.js sketch</title>
73
+
74
+ <!-- Standard bundle (with embedded UrsaFont) -->
75
+ <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
76
+ </head>
77
+ <body>
78
+ <script src="sketch.js"></script>
79
+ </body>
80
+ </html>
81
+ ```
82
+
83
+ ```javascript
84
+ // sketch.js
85
+ const t = textmode.create({
86
+ width: window.innerWidth,
87
+ height: window.innerHeight,
88
+ fontSize: 16,
89
+ frameRate: 60
90
+ });
91
+
92
+ t.setup(() => {
93
+ // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
94
+ });
95
+
96
+ t.draw(() => {
97
+ t.background(32); // Dark gray background
98
+
99
+ t.char('A');
100
+ t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
101
+ t.translate(-t.grid.cols / 4, -t.grid.rows / 4);
102
+ t.rect(t.grid.cols / 2, t.grid.rows / 2);
103
+
104
+ // ...add your drawing code here!
105
+ });
106
+
107
+ t.windowResized(() => {
108
+ t.resizeCanvas(window.innerWidth, window.innerHeight);
109
+ });
110
+ ```
111
+
112
+ #### ESM
113
+
114
+ To use `textmode.js` in an ESM environment, you can install it via `npm`:
115
+
116
+ ```bash
117
+ npm install textmode.js
118
+ ```
119
+
120
+ Then, you can import it in your JavaScript or TypeScript files:
121
+
122
+ ```html
123
+ <!-- index.html -->
124
+ <!DOCTYPE html>
125
+ <html lang="en">
126
+ <head>
127
+ <meta charset="utf-8">
128
+ <title>textmode.js sketch</title>
129
+ </head>
130
+ <body>
131
+ <script type="module" src="./sketch.js"></script>
132
+ </body>
133
+ </html>
134
+ ```
135
+
136
+ ```javascript
137
+ // sketch.js
138
+ // Standard bundle (with embedded UrsaFont)
139
+ import { textmode } from 'textmode.js';
140
+
141
+ const t = textmode.create({
142
+ width: window.innerWidth,
143
+ height: window.innerHeight,
144
+ fontSize: 16,
145
+ frameRate: 60
146
+ });
147
+
148
+ t.setup(() => {
149
+ // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
150
+ });
151
+
152
+ t.draw(() => {
153
+ t.background(32); // Dark gray background
154
+
155
+ t.char('A');
156
+ t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
157
+ t.translate(-t.grid.cols / 4, -t.grid.rows / 4);
158
+ t.rect(t.grid.cols / 2, t.grid.rows / 2);
159
+
160
+ // ...add your drawing code here!
161
+ });
162
+
163
+ t.windowResized(() => {
164
+ t.resizeCanvas(window.innerWidth, window.innerHeight);
165
+ });
166
+ ```
167
+
168
+ ## Next steps
169
+
170
+ 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:
171
+
172
+ 📚 **[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.
173
+
174
+ 🎨 **[Try the Web Editor](https://editor.textmode.art)** to experiment with `textmode.js` without setting up a local environment.
175
+
176
+ ## Acknowledgements
177
+
178
+ `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).
179
+
180
+ `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/).