textmode.export.js 1.2.1 → 1.2.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 +170 -172
- package/dist/textmode.export.esm.js +963 -944
- package/dist/textmode.export.umd.js +2 -2
- package/dist/types/exporters/base/DataExtractor.d.ts +2 -1
- package/dist/types/exporters/base/DataExtractor.d.ts.map +1 -1
- package/dist/types/exporters/base/FileHandler.d.ts +3 -0
- package/dist/types/exporters/base/FileHandler.d.ts.map +1 -1
- package/dist/types/exporters/gif/GIFExporter.d.ts +5 -2
- package/dist/types/exporters/gif/GIFExporter.d.ts.map +1 -1
- package/dist/types/exporters/gif/GIFRecorder.d.ts +3 -3
- package/dist/types/exporters/gif/GIFRecorder.d.ts.map +1 -1
- package/dist/types/exporters/gif/types.d.ts.map +1 -1
- package/dist/types/exporters/image/ImageExporter.d.ts +7 -2
- package/dist/types/exporters/image/ImageExporter.d.ts.map +1 -1
- package/dist/types/exporters/image/index.d.ts +1 -1
- package/dist/types/exporters/image/index.d.ts.map +1 -1
- package/dist/types/exporters/image/types.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGContentGenerator.d.ts +9 -1
- package/dist/types/exporters/svg/SVGContentGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGDataExtractor.d.ts +3 -1
- package/dist/types/exporters/svg/SVGDataExtractor.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGExporter.d.ts +3 -0
- package/dist/types/exporters/svg/SVGExporter.d.ts.map +1 -1
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts +8 -4
- package/dist/types/exporters/svg/SVGPathGenerator.d.ts.map +1 -1
- package/dist/types/exporters/svg/index.d.ts +1 -1
- package/dist/types/exporters/svg/index.d.ts.map +1 -1
- package/dist/types/exporters/svg/types.d.ts.map +1 -1
- package/dist/types/exporters/txt/TXTExporter.d.ts +4 -0
- package/dist/types/exporters/txt/TXTExporter.d.ts.map +1 -1
- package/dist/types/exporters/txt/index.d.ts.map +1 -1
- package/dist/types/exporters/txt/types.d.ts.map +1 -1
- package/dist/types/exporters/video/VideoExporter.d.ts +5 -2
- package/dist/types/exporters/video/VideoExporter.d.ts.map +1 -1
- package/dist/types/exporters/video/VideoRecorder.d.ts +3 -3
- package/dist/types/exporters/video/VideoRecorder.d.ts.map +1 -1
- package/dist/types/exporters/video/index.d.ts +1 -1
- package/dist/types/exporters/video/index.d.ts.map +1 -1
- package/dist/types/exporters/video/types.d.ts +2 -2
- package/dist/types/exporters/video/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/overlay/blades/Blade.d.ts +6 -1
- package/dist/types/overlay/blades/Blade.d.ts.map +1 -1
- package/dist/types/overlay/blades/GIFBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/ImageBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/SVGBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/TextBlade.d.ts.map +1 -1
- package/dist/types/overlay/blades/VideoBlade.d.ts.map +1 -1
- package/dist/types/overlay/components/actions/Button.d.ts.map +1 -1
- package/dist/types/overlay/components/base/Component.d.ts.map +1 -1
- package/dist/types/overlay/components/base/Container.d.ts.map +1 -1
- package/dist/types/overlay/components/base/Field.d.ts.map +1 -1
- package/dist/types/overlay/components/display/Header.d.ts.map +1 -1
- package/dist/types/overlay/components/display/StatusDisplay.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/CheckboxInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/NumberInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/RangeInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/SelectInput.d.ts.map +1 -1
- package/dist/types/overlay/components/inputs/TextInput.d.ts.map +1 -1
- package/dist/types/overlay/core/EventBus.d.ts +1 -0
- package/dist/types/overlay/core/EventBus.d.ts.map +1 -1
- package/dist/types/overlay/core/OverlayController.d.ts.map +1 -1
- package/dist/types/overlay/core/StateManager.d.ts.map +1 -1
- package/dist/types/overlay/formatRegistry.d.ts.map +1 -1
- package/dist/types/overlay/index.d.ts +1 -0
- package/dist/types/overlay/index.d.ts.map +1 -1
- package/dist/types/overlay/models/FormatDefinition.d.ts +3 -3
- package/dist/types/overlay/models/FormatDefinition.d.ts.map +1 -1
- package/dist/types/overlay/models/OverlayEvents.d.ts.map +1 -1
- package/dist/types/overlay/models/OverlayState.d.ts.map +1 -1
- package/dist/types/overlay/services/ClipboardService.d.ts +7 -2
- package/dist/types/overlay/services/ClipboardService.d.ts.map +1 -1
- package/dist/types/overlay/services/ExportService.d.ts.map +1 -1
- package/dist/types/overlay/services/PositionService.d.ts.map +1 -1
- package/dist/types/overlay/types.d.ts.map +1 -1
- package/dist/types/types.d.ts +68 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/pixels.d.ts +1 -0
- package/dist/types/utils/pixels.d.ts.map +1 -1
- package/package.json +115 -71
package/README.md
CHANGED
|
@@ -1,172 +1,170 @@
|
|
|
1
|
-
# textmode.export.js (✿◕‿◕)ノ
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
|
|
5
|
-
| [](https://www.typescriptlang.org/) [](https://vitejs.dev/) | [](docs/README.md) [](https://code.textmode.art/docs/exporting.html) [](https://discord.gg/sjrw8QXNks) | [](https://ko-fi.com/V7V8JG2FY) [ that adds various export options to your `Textmodifier` instance, including:
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
t.setup(() => {
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
t.draw(() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// Control the export overlay UI at runtime
|
|
81
|
-
// t.exportOverlay.hide(); // Hide the overlay
|
|
82
|
-
// t.exportOverlay.show(); // Show the overlay
|
|
83
|
-
// t.exportOverlay.toggle(); // Toggle visibility
|
|
84
|
-
|
|
85
|
-
t.windowResized(() => {
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
#### ESM
|
|
91
|
-
|
|
92
|
-
To use `textmode.export.js` in an ESM environment, you can install it via `npm`:
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
npm install textmode.export.js
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Then, you can import it in your JavaScript or TypeScript files:
|
|
99
|
-
|
|
100
|
-
```html
|
|
101
|
-
<!-- index.html -->
|
|
102
|
-
<!DOCTYPE html>
|
|
103
|
-
<html lang="en">
|
|
104
|
-
<head>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
</head>
|
|
108
|
-
<body>
|
|
109
|
-
|
|
110
|
-
</body>
|
|
111
|
-
</html>
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
```javascript
|
|
115
|
-
// sketch.js
|
|
116
|
-
import { textmode } from 'textmode.js';
|
|
117
|
-
import { ExportPlugin } from 'textmode.export.js';
|
|
118
|
-
|
|
119
|
-
const t = textmode.create({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
//
|
|
151
|
-
// t.exportOverlay.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Animated GIF export relies on [`gifenc`](https://github.com/mattdesl/gifenc) by [**Matt DesLauriers**](https://github.com/mattdesl), available under the [**MIT License**](https://opensource.org/licenses/MIT).
|
|
1
|
+
# textmode.export.js (✿◕‿◕)ノ
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
| [](https://www.typescriptlang.org/) [](https://vitejs.dev/) | [](docs/README.md) [](https://code.textmode.art/docs/exporting.html) [](https://discord.gg/sjrw8QXNks) | [](https://ko-fi.com/V7V8JG2FY) [](https://github.com/sponsors/humanbydefinition) |
|
|
6
|
+
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
`textmode.export.js` is an add-on library for [`textmode.js`](https://github.com/humanbydefinition/textmode.js) that adds various export options to your `Textmodifier` instance, including:
|
|
11
|
+
|
|
12
|
+
- Plain text (`.txt`)
|
|
13
|
+
- Image files (`.png`, `.jpg`, `.webp`)
|
|
14
|
+
- Animated image files (`.gif`)
|
|
15
|
+
- Video files (`.webm`)
|
|
16
|
+
- Scalable vector graphics (`.svg`)
|
|
17
|
+
|
|
18
|
+
Besides exporting programatically, `textmode.export.js` also provides an overlay UI for users to easily export their creations.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### Prerequisites
|
|
23
|
+
|
|
24
|
+
- The latest `textmode.export.js` version requires `textmode.js` v0.7.0 or later.
|
|
25
|
+
|
|
26
|
+
### UMD
|
|
27
|
+
|
|
28
|
+
To use `textmode.export.js` in a UMD environment, download the latest `umd` build from the [**GitHub releases page**](https://github.com/humanbydefinition/textmode.export.js/releases/) or import it directly from a CDN like [**jsDelivr**](https://www.jsdelivr.com/package/npm/textmode.export.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:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<!-- index.html -->
|
|
32
|
+
<!DOCTYPE html>
|
|
33
|
+
<html>
|
|
34
|
+
<head>
|
|
35
|
+
<title>textmode.js sketch</title>
|
|
36
|
+
|
|
37
|
+
<!-- Import textmode.js from jsDelivr CDN -->
|
|
38
|
+
<script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
|
|
39
|
+
|
|
40
|
+
<!-- Import textmode.export.js from jsDelivr CDN -->
|
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/textmode.export.js@latest/dist/textmode.export.umd.js"></script>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<script src="sketch.js"></script>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// sketch.js
|
|
51
|
+
const t = textmode.create({
|
|
52
|
+
width: window.innerWidth,
|
|
53
|
+
height: window.innerHeight,
|
|
54
|
+
fontSize: 16,
|
|
55
|
+
frameRate: 60,
|
|
56
|
+
plugins: [ExportPlugin],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
t.setup(() => {
|
|
60
|
+
// Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
t.draw(() => {
|
|
64
|
+
t.background(32); // Dark gray background
|
|
65
|
+
|
|
66
|
+
t.char('A');
|
|
67
|
+
t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
|
|
68
|
+
t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
|
|
69
|
+
|
|
70
|
+
// ...add your drawing code here!
|
|
71
|
+
|
|
72
|
+
if (t.frameCount === 60) {
|
|
73
|
+
t.saveCanvas({
|
|
74
|
+
format: 'png',
|
|
75
|
+
filename: 'my-sketch',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Control the export overlay UI at runtime
|
|
81
|
+
// t.exportOverlay.hide(); // Hide the overlay
|
|
82
|
+
// t.exportOverlay.show(); // Show the overlay
|
|
83
|
+
// t.exportOverlay.toggle(); // Toggle visibility
|
|
84
|
+
|
|
85
|
+
t.windowResized(() => {
|
|
86
|
+
t.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### ESM
|
|
91
|
+
|
|
92
|
+
To use `textmode.export.js` in an ESM environment, you can install it via `npm`:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npm install textmode.export.js
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then, you can import it in your JavaScript or TypeScript files:
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<!-- index.html -->
|
|
102
|
+
<!DOCTYPE html>
|
|
103
|
+
<html lang="en">
|
|
104
|
+
<head>
|
|
105
|
+
<meta charset="utf-8" />
|
|
106
|
+
<title>textmode.js sketch</title>
|
|
107
|
+
</head>
|
|
108
|
+
<body>
|
|
109
|
+
<script type="module" src="./sketch.js"></script>
|
|
110
|
+
</body>
|
|
111
|
+
</html>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
// sketch.js
|
|
116
|
+
import { textmode } from 'textmode.js';
|
|
117
|
+
import { ExportPlugin } from 'textmode.export.js';
|
|
118
|
+
|
|
119
|
+
const t = textmode.create({
|
|
120
|
+
width: window.innerWidth,
|
|
121
|
+
height: window.innerHeight,
|
|
122
|
+
fontSize: 16,
|
|
123
|
+
frameRate: 60,
|
|
124
|
+
plugins: [ExportPlugin],
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
t.setup(() => {
|
|
128
|
+
// Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
t.draw(() => {
|
|
132
|
+
t.background(32); // Dark gray background
|
|
133
|
+
|
|
134
|
+
t.char('A');
|
|
135
|
+
t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
|
|
136
|
+
t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
|
|
137
|
+
|
|
138
|
+
// ...add your drawing code here!
|
|
139
|
+
|
|
140
|
+
if (t.frameCount === 60) {
|
|
141
|
+
t.saveCanvas({
|
|
142
|
+
format: 'png',
|
|
143
|
+
filename: 'my-sketch',
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Control the export overlay UI at runtime
|
|
149
|
+
// t.exportOverlay.hide(); // Hide the overlay
|
|
150
|
+
// t.exportOverlay.show(); // Show the overlay
|
|
151
|
+
// t.exportOverlay.toggle(); // Toggle visibility
|
|
152
|
+
|
|
153
|
+
t.windowResized(() => {
|
|
154
|
+
t.resizeCanvas(window.innerWidth, window.innerHeight);
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Next steps
|
|
159
|
+
|
|
160
|
+
Now that you have `textmode.export.js` set up, you can explore the following resources to learn more about its features and capabilities:
|
|
161
|
+
|
|
162
|
+
📚 **[Visit the Official Documentation](https://code.textmode.art/docs/exporting.html)** for a detailed guide on how to use the `textmode.export.js` and all its features.
|
|
163
|
+
|
|
164
|
+
🔍 **[Browse the TypeDoc API reference](docs/README.md)** hosted right here in the repository for in-depth API details.
|
|
165
|
+
|
|
166
|
+
## Acknowledgements
|
|
167
|
+
|
|
168
|
+
`textmode.export.js` packages [`webm-writer-js`](https://github.com/thenickdude/webm-writer-js) by [**Nicholas Sherlock**](https://github.com/thenickdude) to provide WebM video export support. `webm-writer-js` is distributed under the [**WTFPL v2**](https://en.wikipedia.org/wiki/WTFPL) license.
|
|
169
|
+
|
|
170
|
+
Animated GIF export relies on [`gifenc`](https://github.com/mattdesl/gifenc) by [**Matt DesLauriers**](https://github.com/mattdesl), available under the [**MIT License**](https://opensource.org/licenses/MIT).
|