@thi.ng/rasterize 1.0.101 → 1.0.103
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 +1 -1
- package/README.md +1 -1
- package/draw.js +2 -4
- package/line.js +1 -2
- package/package.json +14 -14
- package/poly.js +2 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/draw.js
CHANGED
|
@@ -2,8 +2,7 @@ import { isFunction } from "@thi.ng/checks/is-function";
|
|
|
2
2
|
import { isPrimitive } from "@thi.ng/checks/is-primitive";
|
|
3
3
|
const __draw2D = (pts, grid, val) => isFunction(val) ? __drawShader2D(pts, grid, val) : __drawSolid2D(pts, grid, val);
|
|
4
4
|
const __drawSolid2D = (pts, grid, val) => {
|
|
5
|
-
if (!pts)
|
|
6
|
-
return grid;
|
|
5
|
+
if (!pts) return grid;
|
|
7
6
|
if (isPrimitive(val)) {
|
|
8
7
|
const {
|
|
9
8
|
data,
|
|
@@ -21,8 +20,7 @@ const __drawSolid2D = (pts, grid, val) => {
|
|
|
21
20
|
return grid;
|
|
22
21
|
};
|
|
23
22
|
const __drawShader2D = (pts, grid, shader) => {
|
|
24
|
-
if (!pts)
|
|
25
|
-
return grid;
|
|
23
|
+
if (!pts) return grid;
|
|
26
24
|
if (isPrimitive(grid.getAtUnsafe(0, 0))) {
|
|
27
25
|
const {
|
|
28
26
|
data,
|
package/line.js
CHANGED
|
@@ -8,8 +8,7 @@ const drawLine = (grid, x1, y1, x2, y2, val) => __draw2D(
|
|
|
8
8
|
const traceLine = (grid, x1, y1, x2, y2, fn) => {
|
|
9
9
|
const pts = lineClipped(x1, y1, x2, y2, 0, 0, grid.size[0], grid.size[1]);
|
|
10
10
|
if (pts) {
|
|
11
|
-
for (let p of pts)
|
|
12
|
-
fn(p);
|
|
11
|
+
for (let p of pts) fn(p);
|
|
13
12
|
}
|
|
14
13
|
return grid;
|
|
15
14
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rasterize",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.103",
|
|
4
4
|
"description": "2D shape drawing & rasterization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/rasterize",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,19 +36,19 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/checks": "^3.6.
|
|
41
|
-
"@thi.ng/equiv": "^2.1.
|
|
42
|
-
"@thi.ng/grid-iterators": "^4.0.
|
|
43
|
-
"@thi.ng/porter-duff": "^2.1.
|
|
44
|
-
"@thi.ng/random": "^3.
|
|
45
|
-
"@thi.ng/transducers": "^9.0.
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/checks": "^3.6.5",
|
|
41
|
+
"@thi.ng/equiv": "^2.1.59",
|
|
42
|
+
"@thi.ng/grid-iterators": "^4.0.75",
|
|
43
|
+
"@thi.ng/porter-duff": "^2.1.80",
|
|
44
|
+
"@thi.ng/random": "^3.8.1",
|
|
45
|
+
"@thi.ng/transducers": "^9.0.6"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@microsoft/api-extractor": "^7.
|
|
49
|
-
"esbuild": "^0.
|
|
50
|
-
"typedoc": "^0.25.
|
|
51
|
-
"typescript": "^5.
|
|
48
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
49
|
+
"esbuild": "^0.21.5",
|
|
50
|
+
"typedoc": "^0.25.13",
|
|
51
|
+
"typescript": "^5.5.2"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"2d",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"status": "alpha",
|
|
120
120
|
"year": 2021
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
123
123
|
}
|
package/poly.js
CHANGED
|
@@ -18,8 +18,7 @@ const fillPoly = (grid, pts, val) => {
|
|
|
18
18
|
maxX = Math.min(maxX | 0, width - 1);
|
|
19
19
|
minY = Math.max(minY | 0, 0);
|
|
20
20
|
maxY = Math.min(maxY | 0, height - 1);
|
|
21
|
-
if (minX >= width || maxX < 0 || minY >= height || maxY < 0)
|
|
22
|
-
return;
|
|
21
|
+
if (minX >= width || maxX < 0 || minY >= height || maxY < 0) return;
|
|
23
22
|
let i = 0;
|
|
24
23
|
let k = 0;
|
|
25
24
|
let j;
|
|
@@ -38,8 +37,7 @@ const fillPoly = (grid, pts, val) => {
|
|
|
38
37
|
isec.sort((a, b) => a - b);
|
|
39
38
|
for (i = 0; i < k; i += 2) {
|
|
40
39
|
let x1 = isec[i];
|
|
41
|
-
if (x1 > maxX)
|
|
42
|
-
break;
|
|
40
|
+
if (x1 > maxX) break;
|
|
43
41
|
let x2 = isec[i + 1];
|
|
44
42
|
if (x2 > minX) {
|
|
45
43
|
x1 < minX && (x1 = minX);
|