ntk 8.28.0 → 8.29.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/lib/renderingcontext_2d.js +52 -2
- package/package.json +3 -3
|
@@ -655,6 +655,30 @@ const GCO_TO_PICTOP = {
|
|
|
655
655
|
lighter: "Add",
|
|
656
656
|
};
|
|
657
657
|
|
|
658
|
+
// The blend modes, which RENDER has from 0.11 (Multiply .. HSLLuminosity):
|
|
659
|
+
// what a pixel comes to is a function of both colours, as CSS's
|
|
660
|
+
// mix-blend-mode has it. A server that answers QueryVersion below 0.11 raises
|
|
661
|
+
// BadPictOp for every one of them, after the call has returned, so the setter
|
|
662
|
+
// takes one of these names only where the server has them (`_blendModes`).
|
|
663
|
+
// Reading the name back is how a caller asks whether it will be drawn.
|
|
664
|
+
const BLEND_TO_PICTOP = {
|
|
665
|
+
multiply: "Multiply",
|
|
666
|
+
screen: "Screen",
|
|
667
|
+
overlay: "Overlay",
|
|
668
|
+
darken: "Darken",
|
|
669
|
+
lighten: "Lighten",
|
|
670
|
+
"color-dodge": "ColorDodge",
|
|
671
|
+
"color-burn": "ColorBurn",
|
|
672
|
+
"hard-light": "HardLight",
|
|
673
|
+
"soft-light": "SoftLight",
|
|
674
|
+
difference: "Difference",
|
|
675
|
+
exclusion: "Exclusion",
|
|
676
|
+
hue: "HSLHue",
|
|
677
|
+
saturation: "HSLSaturation",
|
|
678
|
+
color: "HSLColor",
|
|
679
|
+
luminosity: "HSLLuminosity",
|
|
680
|
+
};
|
|
681
|
+
|
|
658
682
|
// The ops whose result is the destination wherever the mask is zero. Only
|
|
659
683
|
// those may have a drawing's mask split into several boxes (maskcluster.js):
|
|
660
684
|
// what the split gives up is the gaps between the boxes, and for these ops
|
|
@@ -663,6 +687,11 @@ const GCO_TO_PICTOP = {
|
|
|
663
687
|
// the source — or nothing — across the whole box, so they keep one. Nor can
|
|
664
688
|
// a path clip be folded into their mask: it is applied after them instead
|
|
665
689
|
// (`_clipAfter`).
|
|
690
|
+
//
|
|
691
|
+
// Every blend mode is one of them: a transparent source leaves the
|
|
692
|
+
// destination as it was. And a clip folded into the mask comes to what it
|
|
693
|
+
// would after the op, since each is linear in the source — through a mask of
|
|
694
|
+
// a half, `multiply` is half of the way to `multiply`.
|
|
666
695
|
const MASK_BOUNDED_OPS = [
|
|
667
696
|
"Over",
|
|
668
697
|
"OverReverse",
|
|
@@ -670,6 +699,7 @@ const MASK_BOUNDED_OPS = [
|
|
|
670
699
|
"Atop",
|
|
671
700
|
"Xor",
|
|
672
701
|
"Add",
|
|
702
|
+
...Object.values(BLEND_TO_PICTOP),
|
|
673
703
|
];
|
|
674
704
|
|
|
675
705
|
// and what they are clustered with instead: one mask, exactly as before
|
|
@@ -1297,11 +1327,31 @@ class RenderingContext2d {
|
|
|
1297
1327
|
}
|
|
1298
1328
|
|
|
1299
1329
|
_op() {
|
|
1300
|
-
|
|
1330
|
+
const name = Object.hasOwn(GCO_TO_PICTOP, this._gco)
|
|
1331
|
+
? GCO_TO_PICTOP[this._gco]
|
|
1332
|
+
: BLEND_TO_PICTOP[this._gco];
|
|
1333
|
+
return this.Render.PictOp[name];
|
|
1301
1334
|
}
|
|
1302
1335
|
|
|
1336
|
+
/**
|
|
1337
|
+
* Whether the server composites RENDER 0.11's blend operators: whether it
|
|
1338
|
+
* answered QueryVersion with 0.11 or later. Every X.Org server since 2009
|
|
1339
|
+
* does — Xorg, Xvfb, Xwayland, XQuartz — and so does node-x11's
|
|
1340
|
+
* in-process one, which composites them from the release this needs.
|
|
1341
|
+
*/
|
|
1342
|
+
_blendModes() {
|
|
1343
|
+
const [major, minor] = this.Render.version || [0, 0];
|
|
1344
|
+
return major > 0 || minor >= 11;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// An operator canvas names and this context cannot draw is ignored, as a
|
|
1348
|
+
// browser ignores one it does not know: the name a caller reads back is
|
|
1349
|
+
// the one that is drawn.
|
|
1303
1350
|
set globalCompositeOperation(value) {
|
|
1304
|
-
if (value
|
|
1351
|
+
if (Object.hasOwn(GCO_TO_PICTOP, value)) this._gco = value;
|
|
1352
|
+
else if (Object.hasOwn(BLEND_TO_PICTOP, value) && this._blendModes()) {
|
|
1353
|
+
this._gco = value;
|
|
1354
|
+
}
|
|
1305
1355
|
}
|
|
1306
1356
|
|
|
1307
1357
|
get globalCompositeOperation() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ntk",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.29.0",
|
|
4
4
|
"description": "Desktop UI toolkit for X11 with canvas-like 2d and OpenGL rendering",
|
|
5
5
|
"author": "Andrey Sidorov <sidorares@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"tiny-inflate": "^1.0.3",
|
|
63
63
|
"unicode-properties": "^1.4.0",
|
|
64
64
|
"unicode-trie": "^2.0.0",
|
|
65
|
-
"x11": "^4.
|
|
65
|
+
"x11": "^4.4.0"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"x11-dri": ">=0.5.0 <1"
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@conventional-commits/parser": "^0.4.1",
|
|
76
|
-
"katex": "^0.
|
|
76
|
+
"katex": "^0.19.1"
|
|
77
77
|
}
|
|
78
78
|
}
|