@lightningtv/solid 3.0.7-1 → 3.0.7-2
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/dist/src/core/intrinsicTypes.d.ts +2 -0
- package/dist/src/core/shaders.js +2 -272
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/primitives/borderBox.jsx +10 -7
- package/dist/src/primitives/borderBox.jsx.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/core/intrinsicTypes.ts +2 -0
- package/src/core/shaders.ts +4 -291
- package/src/primitives/borderBox.tsx +10 -7
- package/dist/src/shaders/Rounded.d.ts +0 -7
- package/dist/src/shaders/Rounded.js +0 -88
- package/dist/src/shaders/Rounded.js.map +0 -1
- package/dist/src/shaders/RoundedWithBorder.d.ts +0 -3
- package/dist/src/shaders/RoundedWithBorder.js +0 -217
- package/dist/src/shaders/RoundedWithBorder.js.map +0 -1
- package/dist/src/shaders/index.d.ts +0 -4
- package/dist/src/shaders/index.js +0 -5
- package/dist/src/shaders/index.js.map +0 -1
- package/dist/src/shaders/templates/RoundedTemplate.d.ts +0 -12
- package/dist/src/shaders/templates/RoundedTemplate.js +0 -48
- package/dist/src/shaders/templates/RoundedTemplate.js.map +0 -1
- package/dist/src/shaders/templates/RoundedWithBorderTemplate.d.ts +0 -20
- package/dist/src/shaders/templates/RoundedWithBorderTemplate.js +0 -93
- package/dist/src/shaders/templates/RoundedWithBorderTemplate.js.map +0 -1
- package/dist/src/shaders/utils.d.ts +0 -3
- package/dist/src/shaders/utils.js +0 -31
- package/dist/src/shaders/utils.js.map +0 -1
- package/src/shaders/Rounded.ts +0 -100
- package/src/shaders/RoundedWithBorder.ts +0 -245
- package/src/shaders/index.ts +0 -4
- package/src/shaders/templates/RoundedTemplate.ts +0 -57
- package/src/shaders/templates/RoundedWithBorderTemplate.ts +0 -110
- package/src/shaders/utils.ts +0 -44
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0CAA0C,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ShaderProps } from '@lightningjs/renderer';
|
|
2
|
-
import { type Vec4 } from '../utils.js';
|
|
3
|
-
export interface RoundedProps {
|
|
4
|
-
radius: Vec4;
|
|
5
|
-
'top-left': number;
|
|
6
|
-
'top-right': number;
|
|
7
|
-
'bottom-right': number;
|
|
8
|
-
'bottom-left': number;
|
|
9
|
-
}
|
|
10
|
-
export declare const RoundedTemplate: {
|
|
11
|
-
props: ShaderProps<RoundedProps>;
|
|
12
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { toValidVec4 } from '../utils.js';
|
|
2
|
-
export const RoundedTemplate = {
|
|
3
|
-
props: {
|
|
4
|
-
radius: {
|
|
5
|
-
default: [0, 0, 0, 0],
|
|
6
|
-
resolve(value) {
|
|
7
|
-
return toValidVec4(value);
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
'top-left': {
|
|
11
|
-
default: 0,
|
|
12
|
-
set(value, props) {
|
|
13
|
-
props.radius[0] = value;
|
|
14
|
-
},
|
|
15
|
-
get(props) {
|
|
16
|
-
return props.radius[0];
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
'top-right': {
|
|
20
|
-
default: 0,
|
|
21
|
-
set(value, props) {
|
|
22
|
-
props.radius[1] = value;
|
|
23
|
-
},
|
|
24
|
-
get(props) {
|
|
25
|
-
return props.radius[1];
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
'bottom-right': {
|
|
29
|
-
default: 0,
|
|
30
|
-
set(value, props) {
|
|
31
|
-
props.radius[2] = value;
|
|
32
|
-
},
|
|
33
|
-
get(props) {
|
|
34
|
-
return props.radius[2];
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
'bottom-left': {
|
|
38
|
-
default: 0,
|
|
39
|
-
set(value, props) {
|
|
40
|
-
props.radius[3] = value;
|
|
41
|
-
},
|
|
42
|
-
get(props) {
|
|
43
|
-
return props.radius[3];
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=RoundedTemplate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RoundedTemplate.js","sourceRoot":"","sources":["../../../../src/shaders/templates/RoundedTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAUrD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE;QACL,MAAM,EAAE;YACN,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACrB,OAAO,CAAC,KAAK;gBACX,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,cAAc,EAAE;YACd,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,aAAa,EAAE;YACb,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;KAC2B;CAC/B,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ShaderProps } from '@lightningjs/renderer';
|
|
2
|
-
import { type Vec4 } from '../utils.js';
|
|
3
|
-
export interface RoundedWithBorderProps {
|
|
4
|
-
radius: Vec4;
|
|
5
|
-
'border-w': Vec4;
|
|
6
|
-
'border-color': number;
|
|
7
|
-
'border-gap': number;
|
|
8
|
-
'border-gapColor': number;
|
|
9
|
-
'top-left': number;
|
|
10
|
-
'top-right': number;
|
|
11
|
-
'bottom-right': number;
|
|
12
|
-
'bottom-left': number;
|
|
13
|
-
'border-top': number;
|
|
14
|
-
'border-right': number;
|
|
15
|
-
'border-bottom': number;
|
|
16
|
-
'border-left': number;
|
|
17
|
-
}
|
|
18
|
-
export declare const RoundedWithBorderTemplate: {
|
|
19
|
-
props: ShaderProps<RoundedWithBorderProps>;
|
|
20
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { toValidVec4 } from '../utils.js';
|
|
2
|
-
export const RoundedWithBorderTemplate = {
|
|
3
|
-
props: {
|
|
4
|
-
radius: {
|
|
5
|
-
default: [0, 0, 0, 0],
|
|
6
|
-
resolve(value) {
|
|
7
|
-
return toValidVec4(value);
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
'top-left': {
|
|
11
|
-
default: 0,
|
|
12
|
-
set(value, props) {
|
|
13
|
-
props.radius[0] = value;
|
|
14
|
-
},
|
|
15
|
-
get(props) {
|
|
16
|
-
return props.radius[0];
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
'top-right': {
|
|
20
|
-
default: 0,
|
|
21
|
-
set(value, props) {
|
|
22
|
-
props.radius[1] = value;
|
|
23
|
-
},
|
|
24
|
-
get(props) {
|
|
25
|
-
return props.radius[1];
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
'bottom-right': {
|
|
29
|
-
default: 0,
|
|
30
|
-
set(value, props) {
|
|
31
|
-
props.radius[2] = value;
|
|
32
|
-
},
|
|
33
|
-
get(props) {
|
|
34
|
-
return props.radius[2];
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
'bottom-left': {
|
|
38
|
-
default: 0,
|
|
39
|
-
set(value, props) {
|
|
40
|
-
props.radius[3] = value;
|
|
41
|
-
},
|
|
42
|
-
get(props) {
|
|
43
|
-
return props.radius[3];
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
'border-w': {
|
|
47
|
-
default: [0, 0, 0, 0],
|
|
48
|
-
resolve(value) {
|
|
49
|
-
return toValidVec4(value);
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
'border-color': 0xffffffff,
|
|
53
|
-
'border-gap': 0,
|
|
54
|
-
'border-gapColor': 0x00000000,
|
|
55
|
-
'border-top': {
|
|
56
|
-
default: 0,
|
|
57
|
-
set(value, props) {
|
|
58
|
-
props['border-w'][0] = value;
|
|
59
|
-
},
|
|
60
|
-
get(props) {
|
|
61
|
-
return props['border-w'][0];
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
'border-right': {
|
|
65
|
-
default: 0,
|
|
66
|
-
set(value, props) {
|
|
67
|
-
props['border-w'][1] = value;
|
|
68
|
-
},
|
|
69
|
-
get(props) {
|
|
70
|
-
return props['border-w'][1];
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
'border-bottom': {
|
|
74
|
-
default: 0,
|
|
75
|
-
set(value, props) {
|
|
76
|
-
props['border-w'][2] = value;
|
|
77
|
-
},
|
|
78
|
-
get(props) {
|
|
79
|
-
return props['border-w'][2];
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
'border-left': {
|
|
83
|
-
default: 0,
|
|
84
|
-
set(value, props) {
|
|
85
|
-
props['border-w'][3] = value;
|
|
86
|
-
},
|
|
87
|
-
get(props) {
|
|
88
|
-
return props['border-w'][3];
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=RoundedWithBorderTemplate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RoundedWithBorderTemplate.js","sourceRoot":"","sources":["../../../../src/shaders/templates/RoundedWithBorderTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAa,MAAM,aAAa,CAAC;AAkBrD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,KAAK,EAAE;QACL,MAAM,EAAE;YACN,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACrB,OAAO,CAAC,KAAK;gBACX,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;SACF;QACD,UAAU,EAAE;YACV,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;SACF;QACD,WAAW,EAAE;YACX,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC;YACD,GAAG,C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,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,UAAU,CAAU,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;SACF;QACD,eAAe,EAAE;YACf,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,UAAU,CAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACzC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,UAAU,CAAU,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;SACF;QACD,aAAa,EAAE;YACb,OAAO,EAAE,CAAC;YACV,GAAG,CAAC,KAAK,EAAE,KAAK;gBACb,KAAK,CAAC,UAAU,CAAU,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;YACzC,CAAC;YACD,GAAG,CAAC,KAAK;gBACP,OAAQ,KAAK,CAAC,UAAU,CAAU,CAAC,CAAC,CAAC,CAAC;YACxC,CAAC;SACF;KACqC;CACzC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export function calcFactoredRadiusArray(radius, width, height, out = [0, 0, 0, 0]) {
|
|
2
|
-
[out[0], out[1], out[2], out[3]] = radius;
|
|
3
|
-
const factor = Math.min(width / Math.max(width, radius[0] + radius[1]), width / Math.max(width, radius[2] + radius[3]), height / Math.max(height, radius[0] + radius[3]), height / Math.max(height, radius[1] + radius[2]), 1);
|
|
4
|
-
out[0] *= factor;
|
|
5
|
-
out[1] *= factor;
|
|
6
|
-
out[2] *= factor;
|
|
7
|
-
out[3] *= factor;
|
|
8
|
-
return out;
|
|
9
|
-
}
|
|
10
|
-
export function toValidVec4(value) {
|
|
11
|
-
if (typeof value === 'number') {
|
|
12
|
-
return [value, value, value, value];
|
|
13
|
-
}
|
|
14
|
-
if (Array.isArray(value)) {
|
|
15
|
-
switch (value.length) {
|
|
16
|
-
default:
|
|
17
|
-
case 4:
|
|
18
|
-
return value;
|
|
19
|
-
case 3:
|
|
20
|
-
return [value[0], value[1], value[2], value[0]];
|
|
21
|
-
case 2:
|
|
22
|
-
return [value[0], value[1], value[0], value[1]];
|
|
23
|
-
case 1:
|
|
24
|
-
return [value[0], value[0], value[0], value[0]];
|
|
25
|
-
case 0:
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return [0, 0, 0, 0];
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/shaders/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,uBAAuB,CACrC,MAAY,EACZ,KAAa,EACb,MAAc,EACd,MAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAExB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CACrB,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAC9C,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAC9C,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAChD,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAChD,CAAC,CACF,CAAC;IACF,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;IACjB,GAAG,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
-
import { calcFactoredRadiusArray, type Vec4 } from './utils.js';
|
|
3
|
-
import {
|
|
4
|
-
RoundedTemplate,
|
|
5
|
-
type RoundedProps,
|
|
6
|
-
} from './templates/RoundedTemplate.js';
|
|
7
|
-
|
|
8
|
-
interface CoreNode {
|
|
9
|
-
w: number;
|
|
10
|
-
h: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Similar to the {@link DefaultShader} but cuts out 4 rounded rectangle corners
|
|
15
|
-
* as defined by the specified corner {@link RoundedProps.radius}
|
|
16
|
-
*/
|
|
17
|
-
export const Rounded: WebGlShaderType<RoundedProps> = {
|
|
18
|
-
props: RoundedTemplate.props,
|
|
19
|
-
update(node: CoreNode) {
|
|
20
|
-
this.uniform4fa(
|
|
21
|
-
'u_radius',
|
|
22
|
-
calcFactoredRadiusArray(this.props!.radius as Vec4, node.w, node.h),
|
|
23
|
-
);
|
|
24
|
-
},
|
|
25
|
-
vertex: `
|
|
26
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
27
|
-
precision highp float;
|
|
28
|
-
# else
|
|
29
|
-
precision mediump float;
|
|
30
|
-
# endif
|
|
31
|
-
|
|
32
|
-
attribute vec2 a_position;
|
|
33
|
-
attribute vec2 a_textureCoords;
|
|
34
|
-
attribute vec4 a_color;
|
|
35
|
-
attribute vec2 a_nodeCoords;
|
|
36
|
-
|
|
37
|
-
uniform vec2 u_resolution;
|
|
38
|
-
uniform float u_pixelRatio;
|
|
39
|
-
|
|
40
|
-
varying vec4 v_color;
|
|
41
|
-
varying vec2 v_textureCoords;
|
|
42
|
-
varying vec2 v_nodeCoords;
|
|
43
|
-
|
|
44
|
-
void main() {
|
|
45
|
-
vec2 normalized = a_position * u_pixelRatio;
|
|
46
|
-
vec2 screenSpace = vec2(2.0 / u_resolution.x, -2.0 / u_resolution.y);
|
|
47
|
-
|
|
48
|
-
v_color = a_color;
|
|
49
|
-
v_nodeCoords = a_nodeCoords;
|
|
50
|
-
v_textureCoords = a_textureCoords;
|
|
51
|
-
|
|
52
|
-
gl_Position = vec4(
|
|
53
|
-
normalized.x * screenSpace.x - 1.0,
|
|
54
|
-
normalized.y * -abs(screenSpace.y) + 1.0,
|
|
55
|
-
0.0,
|
|
56
|
-
1.0
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
fragment: `
|
|
61
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
62
|
-
precision highp float;
|
|
63
|
-
# else
|
|
64
|
-
precision mediump float;
|
|
65
|
-
# endif
|
|
66
|
-
|
|
67
|
-
uniform vec2 u_dimensions;
|
|
68
|
-
uniform float u_alpha;
|
|
69
|
-
uniform float u_pixelRatio;
|
|
70
|
-
uniform sampler2D u_texture;
|
|
71
|
-
uniform vec4 u_radius;
|
|
72
|
-
|
|
73
|
-
varying vec4 v_color;
|
|
74
|
-
varying vec2 v_textureCoords;
|
|
75
|
-
varying vec2 v_nodeCoords;
|
|
76
|
-
|
|
77
|
-
void main() {
|
|
78
|
-
vec2 halfDimensions = u_dimensions * 0.5;
|
|
79
|
-
vec2 boxUv = v_nodeCoords * u_dimensions - halfDimensions;
|
|
80
|
-
|
|
81
|
-
// Branchless radius selection based on quadrant
|
|
82
|
-
// x: TL, y: TR, z: BR, w: BL
|
|
83
|
-
vec2 stepVal = step(vec2(0.0), boxUv);
|
|
84
|
-
float r = mix(
|
|
85
|
-
mix(u_radius.x, u_radius.y, stepVal.x),
|
|
86
|
-
mix(u_radius.w, u_radius.z, stepVal.x),
|
|
87
|
-
stepVal.y
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
vec2 q = abs(boxUv) - halfDimensions + r;
|
|
91
|
-
float d = min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - r;
|
|
92
|
-
|
|
93
|
-
float edgeWidth = 1.0 / u_pixelRatio;
|
|
94
|
-
float alpha = 1.0 - smoothstep(-0.5 * edgeWidth, 0.5 * edgeWidth, d);
|
|
95
|
-
|
|
96
|
-
vec4 color = texture2D(u_texture, v_textureCoords) * v_color;
|
|
97
|
-
gl_FragColor = color * alpha * u_alpha;
|
|
98
|
-
}
|
|
99
|
-
`,
|
|
100
|
-
};
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { calcFactoredRadiusArray, type Vec4 } from './utils.js';
|
|
2
|
-
import type { WebGlShaderType } from '@lightningjs/renderer/webgl';
|
|
3
|
-
import {
|
|
4
|
-
RoundedWithBorderTemplate,
|
|
5
|
-
type RoundedWithBorderProps,
|
|
6
|
-
} from './templates/RoundedWithBorderTemplate.js';
|
|
7
|
-
|
|
8
|
-
interface CoreNode {
|
|
9
|
-
w: number;
|
|
10
|
-
h: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const RoundedWithBorder: WebGlShaderType<RoundedWithBorderProps> = {
|
|
14
|
-
props: RoundedWithBorderTemplate.props,
|
|
15
|
-
update(node: CoreNode) {
|
|
16
|
-
const props = this.props!;
|
|
17
|
-
const borderWidth = props['border-w'] as Vec4;
|
|
18
|
-
const borderGap = props['border-gap'] || 0;
|
|
19
|
-
|
|
20
|
-
this.uniformRGBA('u_borderColor', props['border-color']);
|
|
21
|
-
this.uniform4fa('u_borderWidth', borderWidth);
|
|
22
|
-
this.uniform1f('u_borderGap', borderGap);
|
|
23
|
-
this.uniformRGBA('u_borderGapColor', props['border-gapColor']);
|
|
24
|
-
|
|
25
|
-
const origWidth = node.w;
|
|
26
|
-
const origHeight = node.h;
|
|
27
|
-
this.uniform2f('u_dimensions_orig', origWidth, origHeight);
|
|
28
|
-
|
|
29
|
-
const expandedWidth =
|
|
30
|
-
origWidth + borderWidth[3] + borderWidth[1] + borderGap * 2; // original + left + right + 2*gap
|
|
31
|
-
const expandedHeight =
|
|
32
|
-
origHeight + borderWidth[0] + borderWidth[2] + borderGap * 2; // original + top + bottom + 2*gap
|
|
33
|
-
|
|
34
|
-
// u_dimensions for the shader's SDF functions should be the expanded size
|
|
35
|
-
this.uniform2f('u_dimensions', expandedWidth, expandedHeight);
|
|
36
|
-
|
|
37
|
-
// The `radius` property is for the content rectangle.
|
|
38
|
-
// Factor it against the original dimensions to prevent self-intersection.
|
|
39
|
-
const contentRadius = calcFactoredRadiusArray(
|
|
40
|
-
this.props!.radius as Vec4,
|
|
41
|
-
origWidth,
|
|
42
|
-
origHeight,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
// From the content radius, calculate the outer radius of the border.
|
|
46
|
-
// For each corner, the total radius is content radius + gap + border thickness.
|
|
47
|
-
// Border thickness at a corner is approximated as the max of the two adjacent border sides.
|
|
48
|
-
const bTop = borderWidth[0],
|
|
49
|
-
bRight = borderWidth[1],
|
|
50
|
-
bBottom = borderWidth[2],
|
|
51
|
-
bLeft = borderWidth[3];
|
|
52
|
-
const outerRadius: Vec4 = [
|
|
53
|
-
Math.max(0, contentRadius[0] + borderGap + Math.max(bTop, bLeft)), // top-left
|
|
54
|
-
Math.max(0, contentRadius[1] + borderGap + Math.max(bTop, bRight)), // top-right
|
|
55
|
-
Math.max(0, contentRadius[2] + borderGap + Math.max(bBottom, bRight)), // bottom-right
|
|
56
|
-
Math.max(0, contentRadius[3] + borderGap + Math.max(bBottom, bLeft)), // bottom-left
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
// The final radius passed to the shader is the outer radius of the whole shape.
|
|
60
|
-
// It also needs to be factored against the expanded dimensions.
|
|
61
|
-
// The shader will then work inwards to calculate the radii for the gap and content.
|
|
62
|
-
this.uniform4fa(
|
|
63
|
-
'u_radius',
|
|
64
|
-
calcFactoredRadiusArray(outerRadius, expandedWidth, expandedHeight),
|
|
65
|
-
);
|
|
66
|
-
},
|
|
67
|
-
vertex: `
|
|
68
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
69
|
-
precision highp float;
|
|
70
|
-
# else
|
|
71
|
-
precision mediump float;
|
|
72
|
-
# endif
|
|
73
|
-
|
|
74
|
-
attribute vec2 a_position;
|
|
75
|
-
attribute vec2 a_textureCoords;
|
|
76
|
-
attribute vec4 a_color;
|
|
77
|
-
attribute vec2 a_nodeCoords;
|
|
78
|
-
|
|
79
|
-
uniform vec2 u_resolution;
|
|
80
|
-
uniform float u_pixelRatio;
|
|
81
|
-
uniform vec2 u_dimensions;
|
|
82
|
-
uniform vec2 u_dimensions_orig;
|
|
83
|
-
|
|
84
|
-
uniform vec4 u_radius;
|
|
85
|
-
uniform vec4 u_borderWidth;
|
|
86
|
-
uniform float u_borderGap;
|
|
87
|
-
|
|
88
|
-
varying vec4 v_color;
|
|
89
|
-
varying vec2 v_textureCoords;
|
|
90
|
-
varying vec2 v_nodeCoords;
|
|
91
|
-
varying vec4 v_borderEndRadius;
|
|
92
|
-
varying vec2 v_borderEndSize;
|
|
93
|
-
|
|
94
|
-
varying vec4 v_innerRadius;
|
|
95
|
-
varying vec2 v_innerSize;
|
|
96
|
-
varying vec2 v_halfDimensions;
|
|
97
|
-
varying float v_borderZero;
|
|
98
|
-
|
|
99
|
-
void main() {
|
|
100
|
-
vec2 screenSpace = vec2(2.0 / u_resolution.x, -2.0 / u_resolution.y);
|
|
101
|
-
|
|
102
|
-
v_color = a_color;
|
|
103
|
-
v_nodeCoords = a_nodeCoords;
|
|
104
|
-
|
|
105
|
-
float bTop = u_borderWidth.x;
|
|
106
|
-
float bRight = u_borderWidth.y;
|
|
107
|
-
float bBottom = u_borderWidth.z;
|
|
108
|
-
float bLeft = u_borderWidth.w;
|
|
109
|
-
float gap = u_borderGap;
|
|
110
|
-
|
|
111
|
-
// Calculate the offset to expand the quad for border and gap
|
|
112
|
-
vec2 expansionOffset = vec2(0.0);
|
|
113
|
-
if (a_nodeCoords.x == 0.0) { // Left edge vertex
|
|
114
|
-
expansionOffset.x = -(bLeft + gap);
|
|
115
|
-
} else { // Right edge vertex (a_nodeCoords.x == 1.0)
|
|
116
|
-
expansionOffset.x = (bRight + gap);
|
|
117
|
-
}
|
|
118
|
-
if (a_nodeCoords.y == 0.0) { // Top edge vertex
|
|
119
|
-
expansionOffset.y = -(bTop + gap);
|
|
120
|
-
} else { // Bottom edge vertex (a_nodeCoords.y == 1.0)
|
|
121
|
-
expansionOffset.y = (bBottom + gap);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
vec2 expanded_a_position = a_position + expansionOffset;
|
|
125
|
-
vec2 normalized = expanded_a_position * u_pixelRatio;
|
|
126
|
-
|
|
127
|
-
// u_dimensions is expanded, u_dimensions_orig is original content size
|
|
128
|
-
v_textureCoords.x = (a_textureCoords.x * u_dimensions.x - (bLeft + gap)) / u_dimensions_orig.x;
|
|
129
|
-
v_textureCoords.y = (a_textureCoords.y * u_dimensions.y - (bTop + gap)) / u_dimensions_orig.y;
|
|
130
|
-
|
|
131
|
-
v_borderZero = (u_borderWidth.x == 0.0 && u_borderWidth.y == 0.0 && u_borderWidth.z == 0.0 && u_borderWidth.w == 0.0) ? 1.0 : 0.0;
|
|
132
|
-
// If there's no border, there's no gap from the border logic perspective
|
|
133
|
-
// The Rounded shader itself would handle radius if borderZero is true.
|
|
134
|
-
v_halfDimensions = u_dimensions * 0.5; // u_dimensions is now expanded_dimensions
|
|
135
|
-
if(v_borderZero == 0.0) {
|
|
136
|
-
// Calculate radius and size for the inner edge of the border (where the gap begins)
|
|
137
|
-
v_borderEndRadius = vec4(
|
|
138
|
-
max(0.0, u_radius.x - max(bTop, bLeft) - 0.5),
|
|
139
|
-
max(0.0, u_radius.y - max(bTop, bRight) - 0.5),
|
|
140
|
-
max(0.0, u_radius.z - max(bBottom, bRight) - 0.5),
|
|
141
|
-
max(0.0, u_radius.w - max(bBottom, bLeft) - 0.5)
|
|
142
|
-
);
|
|
143
|
-
v_borderEndSize = vec2(
|
|
144
|
-
(u_dimensions.x - (bLeft + bRight) - 1.0),
|
|
145
|
-
(u_dimensions.y - (bTop + bBottom) - 1.0)
|
|
146
|
-
) * 0.5;
|
|
147
|
-
|
|
148
|
-
// Calculate radius and size for the content area (after the gap)
|
|
149
|
-
v_innerRadius = vec4(
|
|
150
|
-
max(0.0, u_radius.x - max(bTop, bLeft) - u_borderGap - 0.5),
|
|
151
|
-
max(0.0, u_radius.y - max(bTop, bRight) - u_borderGap - 0.5),
|
|
152
|
-
max(0.0, u_radius.z - max(bBottom, bRight) - u_borderGap - 0.5),
|
|
153
|
-
max(0.0, u_radius.w - max(bBottom, bLeft) - u_borderGap - 0.5)
|
|
154
|
-
);
|
|
155
|
-
v_innerSize = vec2(
|
|
156
|
-
(u_dimensions.x - (bLeft + bRight) - (u_borderGap * 2.0) - 1.0),
|
|
157
|
-
(u_dimensions.y - (bTop + bBottom) - (u_borderGap * 2.0) - 1.0)
|
|
158
|
-
) * 0.5;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
gl_Position = vec4(normalized.x * screenSpace.x - 1.0, normalized.y * -abs(screenSpace.y) + 1.0, 0.0, 1.0);
|
|
162
|
-
gl_Position.y = -sign(screenSpace.y) * gl_Position.y;
|
|
163
|
-
}
|
|
164
|
-
`,
|
|
165
|
-
fragment: `
|
|
166
|
-
# ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
167
|
-
precision highp float;
|
|
168
|
-
# else
|
|
169
|
-
precision mediump float;
|
|
170
|
-
# endif
|
|
171
|
-
|
|
172
|
-
uniform vec2 u_resolution;
|
|
173
|
-
uniform float u_pixelRatio;
|
|
174
|
-
uniform float u_alpha;
|
|
175
|
-
uniform vec2 u_dimensions;
|
|
176
|
-
uniform sampler2D u_texture;
|
|
177
|
-
|
|
178
|
-
uniform vec4 u_radius;
|
|
179
|
-
|
|
180
|
-
uniform vec4 u_borderWidth;
|
|
181
|
-
uniform vec4 u_borderColor;
|
|
182
|
-
uniform vec4 u_borderGapColor;
|
|
183
|
-
|
|
184
|
-
varying vec4 v_borderEndRadius;
|
|
185
|
-
varying vec2 v_borderEndSize;
|
|
186
|
-
|
|
187
|
-
varying vec4 v_color;
|
|
188
|
-
varying vec2 v_textureCoords;
|
|
189
|
-
varying vec2 v_nodeCoords;
|
|
190
|
-
|
|
191
|
-
varying vec2 v_halfDimensions;
|
|
192
|
-
varying vec4 v_innerRadius;
|
|
193
|
-
varying vec2 v_innerSize;
|
|
194
|
-
varying float v_borderZero;
|
|
195
|
-
|
|
196
|
-
float roundedBox(vec2 p, vec2 s, vec4 r) {
|
|
197
|
-
r.xy = (p.x > 0.0) ? r.yz : r.xw;
|
|
198
|
-
r.x = (p.y > 0.0) ? r.y : r.x;
|
|
199
|
-
vec2 q = abs(p) - s + r.x;
|
|
200
|
-
return (min(max(q.x, q.y), 0.0) + length(max(q, 0.0))) - r.x;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
void main() {
|
|
204
|
-
vec4 contentTexColor = texture2D(u_texture, v_textureCoords) * v_color;
|
|
205
|
-
|
|
206
|
-
vec2 boxUv = v_nodeCoords.xy * u_dimensions - v_halfDimensions;
|
|
207
|
-
float outerShapeDist = roundedBox(boxUv, v_halfDimensions, u_radius);
|
|
208
|
-
|
|
209
|
-
float edgeWidth = 1.0 / u_pixelRatio;
|
|
210
|
-
float outerShapeAlpha = 1.0 - smoothstep(-0.5 * edgeWidth, 0.5 * edgeWidth, outerShapeDist);
|
|
211
|
-
|
|
212
|
-
if(v_borderZero == 1.0) { // No border, effectively no gap from border logic
|
|
213
|
-
gl_FragColor = mix(vec4(0.0), contentTexColor, outerShapeAlpha) * u_alpha;
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Adjust boxUv for non-uniform borders
|
|
218
|
-
vec2 adjustedBoxUv = boxUv;
|
|
219
|
-
adjustedBoxUv.x += (u_borderWidth.y - u_borderWidth.w) * 0.5;
|
|
220
|
-
adjustedBoxUv.y += (u_borderWidth.z - u_borderWidth.x) * 0.5;
|
|
221
|
-
|
|
222
|
-
// Inner Border Edge (Gap starts here)
|
|
223
|
-
float borderEndDist = roundedBox(adjustedBoxUv, v_borderEndSize, v_borderEndRadius);
|
|
224
|
-
float borderEndAlpha = 1.0 - smoothstep(-0.5 * edgeWidth, 0.5 * edgeWidth, borderEndDist);
|
|
225
|
-
|
|
226
|
-
// Content Area (Gap ends here)
|
|
227
|
-
float contentDist = roundedBox(adjustedBoxUv, v_innerSize, v_innerRadius);
|
|
228
|
-
float contentAlpha = 1.0 - smoothstep(-0.5 * edgeWidth, 0.5 * edgeWidth, contentDist);
|
|
229
|
-
|
|
230
|
-
// Calculate Masks for mutually exclusive regions based on priority (Border Top, Gap Middle, Content Bottom)
|
|
231
|
-
float borderMask = clamp(outerShapeAlpha - borderEndAlpha, 0.0, 1.0);
|
|
232
|
-
float gapMask = clamp(borderEndAlpha - contentAlpha, 0.0, 1.0);
|
|
233
|
-
|
|
234
|
-
// Composite Layers
|
|
235
|
-
// 1. Content
|
|
236
|
-
vec4 composite = mix(vec4(0.0), contentTexColor, contentAlpha);
|
|
237
|
-
// 2. Gap
|
|
238
|
-
composite = mix(composite, u_borderGapColor, gapMask);
|
|
239
|
-
// 3. Border
|
|
240
|
-
composite = mix(composite, u_borderColor, borderMask);
|
|
241
|
-
|
|
242
|
-
gl_FragColor = composite * u_alpha;
|
|
243
|
-
}
|
|
244
|
-
`,
|
|
245
|
-
};
|
package/src/shaders/index.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { ShaderProps } from '@lightningjs/renderer';
|
|
2
|
-
import { toValidVec4, type Vec4 } from '../utils.js';
|
|
3
|
-
|
|
4
|
-
export interface RoundedProps {
|
|
5
|
-
radius: Vec4;
|
|
6
|
-
'top-left': number;
|
|
7
|
-
'top-right': number;
|
|
8
|
-
'bottom-right': number;
|
|
9
|
-
'bottom-left': number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const RoundedTemplate = {
|
|
13
|
-
props: {
|
|
14
|
-
radius: {
|
|
15
|
-
default: [0, 0, 0, 0],
|
|
16
|
-
resolve(value) {
|
|
17
|
-
return toValidVec4(value);
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
'top-left': {
|
|
21
|
-
default: 0,
|
|
22
|
-
set(value, props) {
|
|
23
|
-
(props.radius as Vec4)[0] = value;
|
|
24
|
-
},
|
|
25
|
-
get(props) {
|
|
26
|
-
return (props.radius as Vec4)[0];
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
'top-right': {
|
|
30
|
-
default: 0,
|
|
31
|
-
set(value, props) {
|
|
32
|
-
(props.radius as Vec4)[1] = value;
|
|
33
|
-
},
|
|
34
|
-
get(props) {
|
|
35
|
-
return (props.radius as Vec4)[1];
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
'bottom-right': {
|
|
39
|
-
default: 0,
|
|
40
|
-
set(value, props) {
|
|
41
|
-
(props.radius as Vec4)[2] = value;
|
|
42
|
-
},
|
|
43
|
-
get(props) {
|
|
44
|
-
return (props.radius as Vec4)[2];
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
'bottom-left': {
|
|
48
|
-
default: 0,
|
|
49
|
-
set(value, props) {
|
|
50
|
-
(props.radius as Vec4)[3] = value;
|
|
51
|
-
},
|
|
52
|
-
get(props) {
|
|
53
|
-
return (props.radius as Vec4)[3];
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
} as ShaderProps<RoundedProps>,
|
|
57
|
-
};
|