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.
Files changed (81) hide show
  1. package/README.md +170 -172
  2. package/dist/textmode.export.esm.js +963 -944
  3. package/dist/textmode.export.umd.js +2 -2
  4. package/dist/types/exporters/base/DataExtractor.d.ts +2 -1
  5. package/dist/types/exporters/base/DataExtractor.d.ts.map +1 -1
  6. package/dist/types/exporters/base/FileHandler.d.ts +3 -0
  7. package/dist/types/exporters/base/FileHandler.d.ts.map +1 -1
  8. package/dist/types/exporters/gif/GIFExporter.d.ts +5 -2
  9. package/dist/types/exporters/gif/GIFExporter.d.ts.map +1 -1
  10. package/dist/types/exporters/gif/GIFRecorder.d.ts +3 -3
  11. package/dist/types/exporters/gif/GIFRecorder.d.ts.map +1 -1
  12. package/dist/types/exporters/gif/types.d.ts.map +1 -1
  13. package/dist/types/exporters/image/ImageExporter.d.ts +7 -2
  14. package/dist/types/exporters/image/ImageExporter.d.ts.map +1 -1
  15. package/dist/types/exporters/image/index.d.ts +1 -1
  16. package/dist/types/exporters/image/index.d.ts.map +1 -1
  17. package/dist/types/exporters/image/types.d.ts.map +1 -1
  18. package/dist/types/exporters/svg/SVGContentGenerator.d.ts +9 -1
  19. package/dist/types/exporters/svg/SVGContentGenerator.d.ts.map +1 -1
  20. package/dist/types/exporters/svg/SVGDataExtractor.d.ts +3 -1
  21. package/dist/types/exporters/svg/SVGDataExtractor.d.ts.map +1 -1
  22. package/dist/types/exporters/svg/SVGExporter.d.ts +3 -0
  23. package/dist/types/exporters/svg/SVGExporter.d.ts.map +1 -1
  24. package/dist/types/exporters/svg/SVGPathGenerator.d.ts +8 -4
  25. package/dist/types/exporters/svg/SVGPathGenerator.d.ts.map +1 -1
  26. package/dist/types/exporters/svg/index.d.ts +1 -1
  27. package/dist/types/exporters/svg/index.d.ts.map +1 -1
  28. package/dist/types/exporters/svg/types.d.ts.map +1 -1
  29. package/dist/types/exporters/txt/TXTExporter.d.ts +4 -0
  30. package/dist/types/exporters/txt/TXTExporter.d.ts.map +1 -1
  31. package/dist/types/exporters/txt/index.d.ts.map +1 -1
  32. package/dist/types/exporters/txt/types.d.ts.map +1 -1
  33. package/dist/types/exporters/video/VideoExporter.d.ts +5 -2
  34. package/dist/types/exporters/video/VideoExporter.d.ts.map +1 -1
  35. package/dist/types/exporters/video/VideoRecorder.d.ts +3 -3
  36. package/dist/types/exporters/video/VideoRecorder.d.ts.map +1 -1
  37. package/dist/types/exporters/video/index.d.ts +1 -1
  38. package/dist/types/exporters/video/index.d.ts.map +1 -1
  39. package/dist/types/exporters/video/types.d.ts +2 -2
  40. package/dist/types/exporters/video/types.d.ts.map +1 -1
  41. package/dist/types/index.d.ts +6 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/overlay/blades/Blade.d.ts +6 -1
  44. package/dist/types/overlay/blades/Blade.d.ts.map +1 -1
  45. package/dist/types/overlay/blades/GIFBlade.d.ts.map +1 -1
  46. package/dist/types/overlay/blades/ImageBlade.d.ts.map +1 -1
  47. package/dist/types/overlay/blades/SVGBlade.d.ts.map +1 -1
  48. package/dist/types/overlay/blades/TextBlade.d.ts.map +1 -1
  49. package/dist/types/overlay/blades/VideoBlade.d.ts.map +1 -1
  50. package/dist/types/overlay/components/actions/Button.d.ts.map +1 -1
  51. package/dist/types/overlay/components/base/Component.d.ts.map +1 -1
  52. package/dist/types/overlay/components/base/Container.d.ts.map +1 -1
  53. package/dist/types/overlay/components/base/Field.d.ts.map +1 -1
  54. package/dist/types/overlay/components/display/Header.d.ts.map +1 -1
  55. package/dist/types/overlay/components/display/StatusDisplay.d.ts.map +1 -1
  56. package/dist/types/overlay/components/inputs/CheckboxInput.d.ts.map +1 -1
  57. package/dist/types/overlay/components/inputs/NumberInput.d.ts.map +1 -1
  58. package/dist/types/overlay/components/inputs/RangeInput.d.ts.map +1 -1
  59. package/dist/types/overlay/components/inputs/SelectInput.d.ts.map +1 -1
  60. package/dist/types/overlay/components/inputs/TextInput.d.ts.map +1 -1
  61. package/dist/types/overlay/core/EventBus.d.ts +1 -0
  62. package/dist/types/overlay/core/EventBus.d.ts.map +1 -1
  63. package/dist/types/overlay/core/OverlayController.d.ts.map +1 -1
  64. package/dist/types/overlay/core/StateManager.d.ts.map +1 -1
  65. package/dist/types/overlay/formatRegistry.d.ts.map +1 -1
  66. package/dist/types/overlay/index.d.ts +1 -0
  67. package/dist/types/overlay/index.d.ts.map +1 -1
  68. package/dist/types/overlay/models/FormatDefinition.d.ts +3 -3
  69. package/dist/types/overlay/models/FormatDefinition.d.ts.map +1 -1
  70. package/dist/types/overlay/models/OverlayEvents.d.ts.map +1 -1
  71. package/dist/types/overlay/models/OverlayState.d.ts.map +1 -1
  72. package/dist/types/overlay/services/ClipboardService.d.ts +7 -2
  73. package/dist/types/overlay/services/ClipboardService.d.ts.map +1 -1
  74. package/dist/types/overlay/services/ExportService.d.ts.map +1 -1
  75. package/dist/types/overlay/services/PositionService.d.ts.map +1 -1
  76. package/dist/types/overlay/types.d.ts.map +1 -1
  77. package/dist/types/types.d.ts +68 -0
  78. package/dist/types/types.d.ts.map +1 -1
  79. package/dist/types/utils/pixels.d.ts +1 -0
  80. package/dist/types/utils/pixels.d.ts.map +1 -1
  81. package/package.json +115 -71
package/README.md CHANGED
@@ -1,172 +1,170 @@
1
- # textmode.export.js (✿◕‿◕)ノ
2
-
3
- <div align="center">
4
-
5
- | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![API](https://img.shields.io/badge/API-typedoc-3178c6?logo=typescript&logoColor=white)](docs/README.md) [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/docs/exporting.html) [![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) |
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
- - Plain text (`.txt`)
12
- - Image files (`.png`, `.jpg`, `.webp`)
13
- - Animated image files (`.gif`)
14
- - Video files (`.webm`)
15
- - Scalable vector graphics (`.svg`)
16
-
17
- Besides exporting programatically, `textmode.export.js` also provides an overlay UI for users to easily export their creations.
18
-
19
- ## Installation
20
-
21
- ### Prerequisites
22
- - The latest `textmode.export.js` version requires `textmode.js` v0.7.0 or later.
23
-
24
- ### UMD
25
-
26
- 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:
27
-
28
- ```html
29
- <!-- index.html -->
30
- <!DOCTYPE html>
31
- <html>
32
- <head>
33
- <title>textmode.js sketch</title>
34
-
35
- <!-- Import textmode.js from jsDelivr CDN -->
36
- <script src="https://cdn.jsdelivr.net/npm/textmode.js@latest/dist/textmode.umd.js"></script>
37
-
38
- <!-- Import textmode.export.js from jsDelivr CDN -->
39
- <script src="https://cdn.jsdelivr.net/npm/textmode.export.js@latest/dist/textmode.export.umd.js"></script>
40
- </head>
41
- <body>
42
- <script src="sketch.js"></script>
43
- </body>
44
- </html>
45
- ```
46
-
47
- ```javascript
48
- // sketch.js
49
- const t = textmode.create({
50
- width: window.innerWidth,
51
- height: window.innerHeight,
52
- fontSize: 16,
53
- frameRate: 60,
54
- plugins: [
55
- ExportPlugin
56
- ]
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: [
125
- ExportPlugin
126
- ]
127
- });
128
-
129
- t.setup(() => {
130
- // Optional setup code here (e.g., load fonts/shaders, initialize variables that access 't')
131
- });
132
-
133
- t.draw(() => {
134
- t.background(32); // Dark gray background
135
-
136
- t.char('A');
137
- t.charColor(255, 0, 0); // Cover the top-left quarter of the grid with a rectangle of red 'A's
138
- t.rect(0, 0, t.grid.cols / 2, t.grid.rows / 2);
139
-
140
- // ...add your drawing code here!
141
-
142
- if (t.frameCount === 60) {
143
- t.saveCanvas({
144
- format: 'png',
145
- filename: 'my-sketch'
146
- });
147
- }
148
- });
149
-
150
- // Control the export overlay UI at runtime
151
- // t.exportOverlay.hide(); // Hide the overlay
152
- // t.exportOverlay.show(); // Show the overlay
153
- // t.exportOverlay.toggle(); // Toggle visibility
154
-
155
- t.windowResized(() => {
156
- t.resizeCanvas(window.innerWidth, window.innerHeight);
157
- });
158
- ```
159
-
160
- ## Next steps
161
-
162
- Now that you have `textmode.export.js` set up, you can explore the following resources to learn more about its features and capabilities:
163
-
164
- 📚 **[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.
165
-
166
- 🔍 **[Browse the TypeDoc API reference](docs/README.md)** hosted right here in the repository for in-depth API details.
167
-
168
- ## Acknowledgements
169
-
170
- `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.
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
+ | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![API](https://img.shields.io/badge/API-typedoc-3178c6?logo=typescript&logoColor=white)](docs/README.md) [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/docs/exporting.html) [![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) |
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).