@driftengine/script 4.12.0 → 4.13.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/capabilities.json
CHANGED
|
@@ -6887,7 +6887,7 @@
|
|
|
6887
6887
|
"scene.write"
|
|
6888
6888
|
],
|
|
6889
6889
|
"deterministic": false,
|
|
6890
|
-
"doc": "The same, multiplied by a colour. White is the identity, so a white texture draws exactly this colour — which is how a solid rectangle is drawn.",
|
|
6890
|
+
"doc": "The same, multiplied by a colour picked for the screen: sRGB, 0 to 1, decoded to linear as a tint on a node is, with alpha kept as given. White is the identity, so a white texture draws exactly this colour — which is how a solid rectangle is drawn.",
|
|
6891
6891
|
"implementation": "drift/2d.tinted"
|
|
6892
6892
|
},
|
|
6893
6893
|
{
|
|
@@ -7421,7 +7421,7 @@
|
|
|
7421
7421
|
"scene.write"
|
|
7422
7422
|
],
|
|
7423
7423
|
"deterministic": false,
|
|
7424
|
-
"doc": "Change a node's background colour. A node with no background gets one.",
|
|
7424
|
+
"doc": "Change a node's background colour, given as picked for the screen: sRGB, 0 to 1, decoded here to the linear light the renderer draws, as a theme's hex token is. Alpha is coverage and is kept as given. A node with no background gets one.",
|
|
7425
7425
|
"implementation": "drift/ui.tint"
|
|
7426
7426
|
},
|
|
7427
7427
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { srgbToLinear } from '@driftengine/core';
|
|
1
2
|
import { createUiInput, drawUiTree, layoutUiTree, routeUiKey, routeUiPointer, setUiFocus, uiNodeNamed, } from '@driftengine/ui2d';
|
|
2
3
|
import { defineCapability } from 'driftscript';
|
|
3
4
|
export const INTERFACE_MODULE = 'drift/ui';
|
|
@@ -89,7 +90,7 @@ export const INTERFACE_CAPABILITIES = [
|
|
|
89
90
|
{ name: 'g', type: 'f32' },
|
|
90
91
|
{ name: 'b', type: 'f32' },
|
|
91
92
|
{ name: 'a', type: 'f32' },
|
|
92
|
-
], 'void', ['scene.write'], "Change a node's background colour. A node with no background gets one."),
|
|
93
|
+
], 'void', ['scene.write'], "Change a node's background colour, given as picked for the screen: sRGB, 0 to 1, decoded here to the linear light the renderer draws, as a theme's hex token is. Alpha is coverage and is kept as given. A node with no background gets one."),
|
|
93
94
|
define('hovered', NAMED, 'bool', ['input.read'], 'Whether the pointer is over a node.'),
|
|
94
95
|
define('pressed', NAMED, 'bool', ['input.read'], 'Whether the pointer went down on a node and has not come up.'),
|
|
95
96
|
define('focused', NAMED, 'bool', ['input.read'], 'Whether a node has the keyboard.'),
|
|
@@ -168,9 +169,10 @@ export function interfaceImplementation() {
|
|
|
168
169
|
happens once per node rather than per frame. */
|
|
169
170
|
if (node.background === null)
|
|
170
171
|
node.background = new Float32Array(4);
|
|
171
|
-
node
|
|
172
|
-
node.background[
|
|
173
|
-
node.background[
|
|
172
|
+
/* A colour a script picks is a display value, and the node's is linear: see `unpackRgba`. */
|
|
173
|
+
node.background[0] = srgbToLinear(r);
|
|
174
|
+
node.background[1] = srgbToLinear(g);
|
|
175
|
+
node.background[2] = srgbToLinear(b);
|
|
174
176
|
node.background[3] = a;
|
|
175
177
|
},
|
|
176
178
|
hovered: (tree, name) => nodeOf(tree, name)?.hovered === true,
|
package/dist/bindings/sprites.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { srgbToLinear } from '@driftengine/core';
|
|
1
2
|
import { createSpriteFrame, drawSprite, drawTilemap, frameOf, setTile, sheetFrame, tileAt, } from '@driftengine/ui2d';
|
|
2
3
|
import { defineCapability } from 'driftscript';
|
|
3
4
|
export const SPRITES_MODULE = 'drift/2d';
|
|
@@ -92,7 +93,7 @@ export const SPRITES_CAPABILITIES = [
|
|
|
92
93
|
{ name: 'g', type: 'f32' },
|
|
93
94
|
{ name: 'b', type: 'f32' },
|
|
94
95
|
{ name: 'a', type: 'f32' },
|
|
95
|
-
], 'void', ['scene.write'], 'The same, multiplied by a colour. White is the identity, so a white texture draws exactly this colour — which is how a solid rectangle is drawn.'),
|
|
96
|
+
], 'void', ['scene.write'], 'The same, multiplied by a colour picked for the screen: sRGB, 0 to 1, decoded to linear as a tint on a node is, with alpha kept as given. White is the identity, so a white texture draws exactly this colour — which is how a solid rectangle is drawn.'),
|
|
96
97
|
define('frame', [
|
|
97
98
|
{ name: 'batch', type: 'SpriteBatch' },
|
|
98
99
|
{ name: 'sheet', type: 'SpriteSheet' },
|
|
@@ -156,9 +157,10 @@ export function spritesImplementation() {
|
|
|
156
157
|
drawSprite(batch, texture, at(x, y, w, h), null, null);
|
|
157
158
|
},
|
|
158
159
|
tinted: (batch, texture, x, y, w, h, r, g, b, a) => {
|
|
159
|
-
|
|
160
|
-
tint[
|
|
161
|
-
tint[
|
|
160
|
+
/* Picked for the screen and decoded, so a white texture draws exactly this colour. */
|
|
161
|
+
tint[0] = srgbToLinear(r);
|
|
162
|
+
tint[1] = srgbToLinear(g);
|
|
163
|
+
tint[2] = srgbToLinear(b);
|
|
162
164
|
tint[3] = a;
|
|
163
165
|
drawSprite(batch, texture, at(x, y, w, h), null, tint);
|
|
164
166
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driftengine/script",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "The drift/* capability bindings: what this engine provides to DriftScript, and the only place the two are coupled",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"driftscript": "1.17.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@driftengine/ai": "4.
|
|
35
|
-
"@driftengine/animation": "4.
|
|
36
|
-
"@driftengine/audio": "4.
|
|
37
|
-
"@driftengine/chemistry": "4.
|
|
38
|
-
"@driftengine/core": "4.
|
|
39
|
-
"@driftengine/editor": "4.
|
|
40
|
-
"@driftengine/entities": "4.
|
|
41
|
-
"@driftengine/network": "4.
|
|
42
|
-
"@driftengine/terrain": "4.
|
|
43
|
-
"@driftengine/ui2d": "4.
|
|
44
|
-
"@driftengine/xr": "4.
|
|
34
|
+
"@driftengine/ai": "4.13.0",
|
|
35
|
+
"@driftengine/animation": "4.13.0",
|
|
36
|
+
"@driftengine/audio": "4.13.0",
|
|
37
|
+
"@driftengine/chemistry": "4.13.0",
|
|
38
|
+
"@driftengine/core": "4.13.0",
|
|
39
|
+
"@driftengine/editor": "4.13.0",
|
|
40
|
+
"@driftengine/entities": "4.13.0",
|
|
41
|
+
"@driftengine/network": "4.13.0",
|
|
42
|
+
"@driftengine/terrain": "4.13.0",
|
|
43
|
+
"@driftengine/ui2d": "4.13.0",
|
|
44
|
+
"@driftengine/xr": "4.13.0"
|
|
45
45
|
},
|
|
46
46
|
"author": "Drift Technologies",
|
|
47
47
|
"repository": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { srgbToLinear } from '@driftengine/core';
|
|
1
2
|
import type { SpriteBatch, UiInput, UiNode } from '@driftengine/ui2d';
|
|
2
3
|
import {
|
|
3
4
|
createUiInput,
|
|
@@ -158,7 +159,7 @@ export const INTERFACE_CAPABILITIES: readonly CapabilityDefinition[] = [
|
|
|
158
159
|
],
|
|
159
160
|
'void',
|
|
160
161
|
['scene.write'],
|
|
161
|
-
"Change a node's background colour. A node with no background gets one.",
|
|
162
|
+
"Change a node's background colour, given as picked for the screen: sRGB, 0 to 1, decoded here to the linear light the renderer draws, as a theme's hex token is. Alpha is coverage and is kept as given. A node with no background gets one.",
|
|
162
163
|
),
|
|
163
164
|
define('hovered', NAMED, 'bool', ['input.read'], 'Whether the pointer is over a node.'),
|
|
164
165
|
define(
|
|
@@ -268,9 +269,10 @@ export function interfaceImplementation(): Record<string, unknown> {
|
|
|
268
269
|
/* A node with no background gets one, which is the only allocation in this module and
|
|
269
270
|
happens once per node rather than per frame. */
|
|
270
271
|
if (node.background === null) node.background = new Float32Array(4);
|
|
271
|
-
node
|
|
272
|
-
node.background[
|
|
273
|
-
node.background[
|
|
272
|
+
/* A colour a script picks is a display value, and the node's is linear: see `unpackRgba`. */
|
|
273
|
+
node.background[0] = srgbToLinear(r);
|
|
274
|
+
node.background[1] = srgbToLinear(g);
|
|
275
|
+
node.background[2] = srgbToLinear(b);
|
|
274
276
|
node.background[3] = a;
|
|
275
277
|
},
|
|
276
278
|
hovered: (tree: UiNode, name: string) => nodeOf(tree, name)?.hovered === true,
|
package/src/bindings/sprites.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { srgbToLinear } from '@driftengine/core';
|
|
1
2
|
import type { SpriteBatch, SpriteSheet, Tilemap } from '@driftengine/ui2d';
|
|
2
3
|
import {
|
|
3
4
|
createSpriteFrame,
|
|
@@ -125,7 +126,7 @@ export const SPRITES_CAPABILITIES: readonly CapabilityDefinition[] = [
|
|
|
125
126
|
],
|
|
126
127
|
'void',
|
|
127
128
|
['scene.write'],
|
|
128
|
-
'The same, multiplied by a colour. White is the identity, so a white texture draws exactly this colour — which is how a solid rectangle is drawn.',
|
|
129
|
+
'The same, multiplied by a colour picked for the screen: sRGB, 0 to 1, decoded to linear as a tint on a node is, with alpha kept as given. White is the identity, so a white texture draws exactly this colour — which is how a solid rectangle is drawn.',
|
|
129
130
|
),
|
|
130
131
|
define(
|
|
131
132
|
'frame',
|
|
@@ -264,9 +265,10 @@ export function spritesImplementation(): Record<string, unknown> {
|
|
|
264
265
|
b: number,
|
|
265
266
|
a: number,
|
|
266
267
|
) => {
|
|
267
|
-
|
|
268
|
-
tint[
|
|
269
|
-
tint[
|
|
268
|
+
/* Picked for the screen and decoded, so a white texture draws exactly this colour. */
|
|
269
|
+
tint[0] = srgbToLinear(r);
|
|
270
|
+
tint[1] = srgbToLinear(g);
|
|
271
|
+
tint[2] = srgbToLinear(b);
|
|
270
272
|
tint[3] = a;
|
|
271
273
|
drawSprite(batch, texture, at(x, y, w, h), null, tint);
|
|
272
274
|
},
|