textmode.js 0.1.1 → 0.1.2
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 +30 -24
- package/dist/textmode.esm.js +627 -277
- package/dist/textmode.esm.min.js +3665 -0
- package/dist/textmode.umd.js +5 -5
- package/dist/textmode.umd.min.js +25 -0
- package/dist/types/ColorPalette.d.ts +2 -2
- package/dist/types/Textmode.d.ts +39 -9
- package/dist/types/export/image/types.d.ts +18 -10
- package/dist/types/export/svg/types.d.ts +14 -5
- package/dist/types/export/txt/types.d.ts +9 -4
- package/dist/types/index.d.ts +3 -3
- package/dist/types/rendering/index.d.ts +4 -0
- package/dist/types/rendering/webgl/Framebuffer.d.ts +6 -2
- package/dist/types/rendering/webgl/Renderer.d.ts +6 -4
- package/dist/types/rendering/webgl/Shader.d.ts +4 -0
- package/dist/types/rendering/webgl/index.d.ts +1 -0
- package/dist/types/textmode/Canvas.d.ts +13 -7
- package/dist/types/textmode/ConversionPipeline.d.ts +16 -4
- package/dist/types/textmode/Textmodifier.d.ts +249 -28
- package/dist/types/textmode/converters/BrightnessConverter.d.ts +2 -2
- package/dist/types/textmode/converters/Converter.d.ts +3 -3
- package/dist/types/textmode/converters/FeatureConverter.d.ts +2 -2
- package/dist/types/textmode/font/TextmodeFont.d.ts +4 -3
- package/dist/types/textmode/font/TextureAtlas.d.ts +2 -2
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
<img
|
|
5
|
+
<img alt="textmodejs_banner" src="https://github.com/user-attachments/assets/f03c2d74-7dc3-45cf-a0a5-043f9438231e" />
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
| [](https://www.typescriptlang.org/) [](https://www.khronos.org/webgl/) [](https://vitejs.dev/) | [](https://code.textmode.art/) [](https://discord.gg/sjrw8QXNks) | [](https://ko-fi.com/V7V8JG2FY) [](https://github.com/sponsors/humanbydefinition) |
|
|
@@ -10,20 +10,21 @@
|
|
|
10
10
|
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
|
-
`textmode.js` is a
|
|
13
|
+
`textmode.js` is a free, lightweight and framework-agnostic creative coding library for real-time ASCII art and textmode experiences in web browsers.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Transform any `<canvas>` or `<video>` element into dynamic ASCII representations with blazing-fast WebGL rendering. Whether you're using p5.js, three.js, or vanilla JavaScript, textmode.js seamlessly integrates with your existing projects to create interactive textmode games, live visual performances, and artistic installations.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
For standalone projects, textmode.js provides its own p5.js-inspired drawing API, letting you create compelling ASCII experiences without additional dependencies. The library powers live coding performances, interactive installations, and digital art projects worldwide, bringing the nostalgic aesthetic of textmode art into modern web development.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
19
|
+
## Features
|
|
20
|
+
- **Dependency-free**: No external libraries required, making it lightweight and easy to integrate into any project.
|
|
21
|
+
- **TTF/OTF font support**: Load and use TrueType and OpenType fonts for rendering textmode art, allowing for a wide range of styles and characters.
|
|
22
|
+
- **Framework-agnostic**: Use `textmode.js` with any JavaScript framework or library, such as `p5.js`, `three.js`, or even vanilla JavaScript.
|
|
23
|
+
- **Standalone drawing API**: Use the built-in `p5.js`-like drawing API for creating textmode art without any other dependencies.
|
|
24
|
+
- **Injectable**: Easily inject `textmode.js` into websites like YouTube to convert `<video>` or `<canvas>` elements into textmode representations for a unique viewing experience.
|
|
25
25
|
- **WebGL1/WebGL2 support**: All shader code provided by `textmode.js` is written in `GLSL ES 1.0`, making it compatible with both `WebGL1` and `WebGL2` contexts, allowing for a wide range of devices to run your ASCII projects.
|
|
26
|
-
- **
|
|
26
|
+
- **Exporting**: Export your creations to various image formats, and as `.txt`, `.svg` and `.json` files for easy sharing, printing and plotting.
|
|
27
|
+
- **Typescript support**: Fully typed library with TypeScript definitions, making it easy to integrate into TypeScript projects and ensuring type safety.
|
|
27
28
|
|
|
28
29
|
## Installation
|
|
29
30
|
|
|
@@ -31,8 +32,8 @@
|
|
|
31
32
|
|
|
32
33
|
To get started with `textmode.js`, you'll need:
|
|
33
34
|
- A **modern web browser** with `WebGL` support
|
|
35
|
+
- A `<canvas>` or `<video>` element in your project *(optional, for capturing content from a different source)*
|
|
34
36
|
- **Node.js 16+** and `npm` *(optional, for ESM installation)*
|
|
35
|
-
- A **HTML canvas element** in your project to apply textmode conversion to
|
|
36
37
|
|
|
37
38
|
### Importing `textmode.js`
|
|
38
39
|
|
|
@@ -56,10 +57,6 @@ To use `textmode.js` in a UMD environment, download the latest `umd` build from
|
|
|
56
57
|
// Reference your existing canvas element
|
|
57
58
|
const canvas = document.querySelector('canvas#myCanvas');
|
|
58
59
|
|
|
59
|
-
if (!canvas) {
|
|
60
|
-
throw new Error('Canvas element not found');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
60
|
// Create a `textmodifier` instance to apply textmode conversion to a given canvas
|
|
64
61
|
const textmodifier = await textmode.create(canvas);
|
|
65
62
|
})();
|
|
@@ -82,15 +79,17 @@ Then, you can import it in your JavaScript or TypeScript files:
|
|
|
82
79
|
import { textmode } from 'textmode.js';
|
|
83
80
|
|
|
84
81
|
(async () => {
|
|
85
|
-
//
|
|
82
|
+
// Canvas example
|
|
86
83
|
const canvas = document.querySelector('canvas#myCanvas');
|
|
87
|
-
|
|
88
|
-
if (!canvas) {
|
|
89
|
-
throw new Error('Canvas element not found');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Create a `textmodifier` instance to apply textmode conversion to a given canvas
|
|
93
84
|
const textmodifier = await textmode.create(canvas);
|
|
85
|
+
|
|
86
|
+
// Video example
|
|
87
|
+
const video = document.querySelector('video#myVideo');
|
|
88
|
+
if (video) {
|
|
89
|
+
const videoTextmodifier = await textmode.create(video);
|
|
90
|
+
// ASCII conversion will update automatically as video plays
|
|
91
|
+
video.play();
|
|
92
|
+
}
|
|
94
93
|
})();
|
|
95
94
|
```
|
|
96
95
|
|
|
@@ -109,4 +108,11 @@ Explore the comprehensive documentation at [code.textmode.art](https://code.text
|
|
|
109
108
|
- Tips and tricks
|
|
110
109
|
- ... and much more!
|
|
111
110
|
|
|
112
|
-
The documentation will help you unlock the full potential of `textmode.js` in your creative coding projects.
|
|
111
|
+
The documentation will help you unlock the full potential of `textmode.js` in your creative coding projects.
|
|
112
|
+
|
|
113
|
+
## Acknowledgements
|
|
114
|
+
|
|
115
|
+
`textmode.js` uses a custom-made 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).
|
|
116
|
+
|
|
117
|
+
The non-minified version of `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/).
|
|
118
|
+
|