@thi.ng/text-canvas 2.4.52 → 2.5.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-08-12T13:14:08Z
3
+ - **Last updated**: 2023-08-14T13:30:45Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [2.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/text-canvas@2.5.0) (2023-08-14)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add imageRawFmtOnly() ([1042a40](https://github.com/thi-ng/umbrella/commit/1042a40))
17
+
12
18
  ### [2.4.40](https://github.com/thi-ng/umbrella/tree/@thi.ng/text-canvas@2.4.40) (2023-03-27)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -68,7 +68,7 @@ For Node.js REPL:
68
68
  const textCanvas = await import("@thi.ng/text-canvas");
69
69
  ```
70
70
 
71
- Package sizes (brotli'd, pre-treeshake): ESM: 5.05 KB
71
+ Package sizes (brotli'd, pre-treeshake): ESM: 5.12 KB
72
72
 
73
73
  ## Dependencies
74
74
 
@@ -90,10 +90,11 @@ directory are using this package.
90
90
 
91
91
  A selection:
92
92
 
93
- | Screenshot | Description | Live demo | Source |
94
- |:-------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------|:--------------------------------------------------------|:-------------------------------------------------------------------------------------|
95
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/text-canvas.png" width="240"/> | 3D wireframe textmode demo | [Demo](https://demo.thi.ng/umbrella/text-canvas/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/text-canvas) |
96
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/text-canvas-image.png" width="240"/> | Textmode image warping w/ 16bit color output | [Demo](https://demo.thi.ng/umbrella/text-canvas-image/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/text-canvas-image) |
93
+ | Screenshot | Description | Live demo | Source |
94
+ |:-------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------|:--------------------------------------------------------|:-------------------------------------------------------------------------------------|
95
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ascii-raymarch.jpg" width="240"/> | ASCII art raymarching with thi.ng/shader-ast & thi.ng/text-canvas | [Demo](https://demo.thi.ng/umbrella/ascii-raymarch/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ascii-raymarch) |
96
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/text-canvas.png" width="240"/> | 3D wireframe textmode demo | [Demo](https://demo.thi.ng/umbrella/text-canvas/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/text-canvas) |
97
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/text-canvas-image.png" width="240"/> | Textmode image warping w/ 16bit color output | [Demo](https://demo.thi.ng/umbrella/text-canvas-image/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/text-canvas-image) |
97
98
 
98
99
  ## API
99
100
 
package/image.d.ts CHANGED
@@ -82,6 +82,18 @@ export declare const image: (canvas: Canvas, x: number, y: number, w: number, h:
82
82
  * @param char -
83
83
  */
84
84
  export declare const imageRaw: (canvas: Canvas, x: number, y: number, w: number, h: number, pixels: ArrayLike<number>, char?: string) => void;
85
+ /**
86
+ * Similar to {@link imageRaw}, but **only** directly modifies the format bits
87
+ * of the specified region (any character data remains intact).
88
+ *
89
+ * @param canvas
90
+ * @param x
91
+ * @param y
92
+ * @param w
93
+ * @param h
94
+ * @param pixels
95
+ */
96
+ export declare const imageRawFmtOnly: (canvas: Canvas, x: number, y: number, w: number, h: number, pixels: ArrayLike<number>) => void;
85
97
  /**
86
98
  * Similar to {@link imageRaw}, but always thresholds pixels given `thresh` and
87
99
  * converts groups of 2x4 pixels into Unicode Braille characters. Each written
package/image.js CHANGED
@@ -201,6 +201,36 @@ export const imageRaw = (canvas, x, y, w, h, pixels, char = "█") => {
201
201
  }
202
202
  }
203
203
  };
204
+ /**
205
+ * Similar to {@link imageRaw}, but **only** directly modifies the format bits
206
+ * of the specified region (any character data remains intact).
207
+ *
208
+ * @param canvas
209
+ * @param x
210
+ * @param y
211
+ * @param w
212
+ * @param h
213
+ * @param pixels
214
+ */
215
+ export const imageRawFmtOnly = (canvas, x, y, w, h, pixels) => {
216
+ x |= 0;
217
+ y |= 0;
218
+ w |= 0;
219
+ h |= 0;
220
+ const { data, width } = canvas;
221
+ const { x1, y1, x2, y2, sx, sy, w: iw, h: ih, } = imgRect(canvas, x, y, w, h);
222
+ if (!iw || !ih)
223
+ return;
224
+ for (let yy = sy, dy = y1; dy < y2; yy++, dy++) {
225
+ let sidx = sx + yy * w;
226
+ let didx = x1 + dy * width;
227
+ for (let xx = sx, dx = x1; dx < x2; xx++, dx++) {
228
+ data[didx] =
229
+ (data[didx] & 0xffff) | ((pixels[sidx++] & 0xffff) << 16);
230
+ didx++;
231
+ }
232
+ }
233
+ };
204
234
  /**
205
235
  * Similar to {@link imageRaw}, but always thresholds pixels given `thresh` and
206
236
  * converts groups of 2x4 pixels into Unicode Braille characters. Each written
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/text-canvas",
3
- "version": "2.4.52",
3
+ "version": "2.5.0",
4
4
  "description": "Text based canvas, drawing, tables with arbitrary formatting (incl. ANSI/HTML)",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -38,11 +38,11 @@
38
38
  "@thi.ng/arrays": "^2.5.19",
39
39
  "@thi.ng/checks": "^3.4.3",
40
40
  "@thi.ng/errors": "^2.3.3",
41
- "@thi.ng/geom-clip-line": "^2.3.24",
41
+ "@thi.ng/geom-clip-line": "^2.3.25",
42
42
  "@thi.ng/math": "^5.5.4",
43
43
  "@thi.ng/strings": "^3.4.11",
44
- "@thi.ng/text-format": "^1.4.10",
45
- "@thi.ng/transducers": "^8.5.4"
44
+ "@thi.ng/text-format": "^1.4.11",
45
+ "@thi.ng/transducers": "^8.5.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@microsoft/api-extractor": "^7.36.4",
@@ -139,5 +139,5 @@
139
139
  ],
140
140
  "year": 2020
141
141
  },
142
- "gitHead": "4154283d772824d4b57d4b7ab97be22a6e1ffdd7\n"
142
+ "gitHead": "4e8f1abeeba7b919e069954eada917ecd2e9a8e9\n"
143
143
  }