ntk 3.9.1 → 3.10.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/color.js +13 -5
- package/lib/index.js +3 -0
- package/package.json +6 -2
package/lib/color.js
CHANGED
|
@@ -43,11 +43,19 @@ function parseHex(value) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Parse a CSS colour to
|
|
47
|
-
* alpha, or null if it is not a colour.
|
|
48
|
-
*
|
|
46
|
+
* Parse a CSS colour to `[r, g, b, a]` floats in 0..1 with **straight**
|
|
47
|
+
* (unassociated) alpha, or null if it is not a colour.
|
|
48
|
+
*
|
|
49
|
+
* `cssColor` is the one to use for anything heading to XRender. This is for
|
|
50
|
+
* the places that genuinely want unassociated components:
|
|
51
|
+
*
|
|
52
|
+
* - **OpenGL.** `glClearColor` and material colours take straight alpha;
|
|
53
|
+
* handing them premultiplied values renders translucent colours dark.
|
|
54
|
+
* - **Interpolating** two colours. Lerp straight, then premultiply once at
|
|
55
|
+
* the end — a round trip back to an `rgba()` string only closes if the
|
|
56
|
+
* components were never scaled.
|
|
49
57
|
*/
|
|
50
|
-
export function
|
|
58
|
+
export function cssColorStraight(value) {
|
|
51
59
|
if (typeof value !== 'string') return null;
|
|
52
60
|
const v = value.trim();
|
|
53
61
|
if (!v) return null;
|
|
@@ -73,6 +81,6 @@ function rawRgba(value) {
|
|
|
73
81
|
* XRender, or null if `value` is not a colour.
|
|
74
82
|
*/
|
|
75
83
|
export function cssColor(value) {
|
|
76
|
-
const straight =
|
|
84
|
+
const straight = cssColorStraight(value);
|
|
77
85
|
return straight && premultiply(straight);
|
|
78
86
|
}
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import SvgView from './widgets/svgview.js';
|
|
|
22
22
|
import MarkdownView from './widgets/markdownview.js';
|
|
23
23
|
import TexView, { configureTex, layoutTex, TexBox } from './widgets/tex.js';
|
|
24
24
|
import { tokenize as highlightCode } from './widgets/highlight.js';
|
|
25
|
+
import { cssColorStraight, premultiply } from './color.js';
|
|
25
26
|
import { cssColor, cssLength } from './widgets/css.js';
|
|
26
27
|
|
|
27
28
|
// rendering context modules register themselves on Drawable
|
|
@@ -135,6 +136,8 @@ export {
|
|
|
135
136
|
configureTex,
|
|
136
137
|
highlightCode,
|
|
137
138
|
cssColor,
|
|
139
|
+
cssColorStraight,
|
|
140
|
+
premultiply,
|
|
138
141
|
cssLength
|
|
139
142
|
};
|
|
140
143
|
// the yoga-layout instance ntk lays HtmlView out with — downstream layout
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ntk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.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",
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
"yoga-layout": "^3.2.1"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
|
-
"test": "NTK_STRICT_COLORS=1 node --test"
|
|
58
|
+
"test": "NTK_STRICT_COLORS=1 node --test",
|
|
59
|
+
"check-release-message": "node scripts/check-release-message.mjs"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@conventional-commits/parser": "^0.4.1"
|
|
59
63
|
}
|
|
60
64
|
}
|