@lightningjs/renderer 3.0.0-beta11 → 3.0.0-beta12

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.
Files changed (132) hide show
  1. package/dist/src/common/CommonTypes.d.ts +2 -2
  2. package/dist/src/core/CoreNode.d.ts +8 -7
  3. package/dist/src/core/CoreNode.js +57 -61
  4. package/dist/src/core/CoreNode.js.map +1 -1
  5. package/dist/src/core/CoreTextNode.js +9 -9
  6. package/dist/src/core/CoreTextNode.js.map +1 -1
  7. package/dist/src/core/Stage.js +4 -4
  8. package/dist/src/core/Stage.js.map +1 -1
  9. package/dist/src/core/lib/textureCompression.js +4 -4
  10. package/dist/src/core/lib/textureCompression.js.map +1 -1
  11. package/dist/src/core/renderers/CoreShaderNode.js +2 -2
  12. package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
  13. package/dist/src/core/renderers/canvas/CanvasRenderer.js +1 -1
  14. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
  15. package/dist/src/core/renderers/canvas/CanvasTexture.js +5 -5
  16. package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -1
  17. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +5 -6
  18. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -1
  19. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +13 -0
  20. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +34 -5
  21. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -1
  22. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +21 -21
  23. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
  24. package/dist/src/core/renderers/webgl/WebGlRenderOp.js +1 -1
  25. package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -1
  26. package/dist/src/core/renderers/webgl/WebGlRenderer.js +12 -11
  27. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
  28. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +2 -2
  29. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
  30. package/dist/src/core/shaders/canvas/Border.js +4 -4
  31. package/dist/src/core/shaders/canvas/Border.js.map +1 -1
  32. package/dist/src/core/shaders/canvas/HolePunch.js +3 -3
  33. package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -1
  34. package/dist/src/core/shaders/canvas/LinearGradient.js +2 -2
  35. package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
  36. package/dist/src/core/shaders/canvas/RadialGradient.js +4 -4
  37. package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
  38. package/dist/src/core/shaders/canvas/Rounded.js +1 -1
  39. package/dist/src/core/shaders/canvas/Rounded.js.map +1 -1
  40. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +3 -3
  41. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -1
  42. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +3 -3
  43. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
  44. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +1 -1
  45. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
  46. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +1 -1
  47. package/dist/src/core/shaders/templates/BorderTemplate.js +10 -10
  48. package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -1
  49. package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +2 -2
  50. package/dist/src/core/shaders/templates/HolePunchTemplate.js +2 -2
  51. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
  52. package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +2 -2
  53. package/dist/src/core/shaders/templates/RadialGradientTemplate.js +2 -2
  54. package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +1 -1
  55. package/dist/src/core/shaders/webgl/Border.js +1 -1
  56. package/dist/src/core/shaders/webgl/Border.js.map +1 -1
  57. package/dist/src/core/shaders/webgl/HolePunch.js +2 -2
  58. package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -1
  59. package/dist/src/core/shaders/webgl/RadialGradient.js +2 -2
  60. package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
  61. package/dist/src/core/shaders/webgl/Rounded.js +1 -1
  62. package/dist/src/core/shaders/webgl/Rounded.js.map +1 -1
  63. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +2 -2
  64. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
  65. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +2 -2
  66. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
  67. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +1 -1
  68. package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +1 -1
  69. package/dist/src/core/textures/ColorTexture.js +1 -1
  70. package/dist/src/core/textures/ColorTexture.js.map +1 -1
  71. package/dist/src/core/textures/ImageTexture.d.ts +2 -2
  72. package/dist/src/core/textures/ImageTexture.js +11 -11
  73. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  74. package/dist/src/core/textures/NoiseTexture.d.ts +2 -2
  75. package/dist/src/core/textures/NoiseTexture.js +6 -6
  76. package/dist/src/core/textures/NoiseTexture.js.map +1 -1
  77. package/dist/src/core/textures/RenderTexture.d.ts +6 -6
  78. package/dist/src/core/textures/RenderTexture.js +10 -10
  79. package/dist/src/core/textures/RenderTexture.js.map +1 -1
  80. package/dist/src/core/textures/SubTexture.d.ts +4 -4
  81. package/dist/src/core/textures/SubTexture.js +8 -8
  82. package/dist/src/core/textures/SubTexture.js.map +1 -1
  83. package/dist/src/core/textures/Texture.d.ts +3 -4
  84. package/dist/src/core/textures/Texture.js +4 -4
  85. package/dist/src/core/textures/Texture.js.map +1 -1
  86. package/dist/src/main-api/Inspector.js +7 -7
  87. package/dist/src/main-api/Inspector.js.map +1 -1
  88. package/dist/src/main-api/Renderer.js +2 -2
  89. package/dist/src/main-api/Renderer.js.map +1 -1
  90. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  91. package/package.json +1 -1
  92. package/src/common/CommonTypes.ts +2 -2
  93. package/src/core/CoreNode.test.ts +12 -12
  94. package/src/core/CoreNode.ts +67 -77
  95. package/src/core/CoreTextNode.ts +9 -9
  96. package/src/core/Stage.ts +4 -4
  97. package/src/core/lib/textureCompression.ts +4 -4
  98. package/src/core/renderers/CoreShaderNode.ts +2 -2
  99. package/src/core/renderers/canvas/CanvasRenderer.ts +2 -2
  100. package/src/core/renderers/canvas/CanvasTexture.ts +5 -5
  101. package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +5 -15
  102. package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +50 -5
  103. package/src/core/renderers/webgl/WebGlCtxTexture.ts +21 -30
  104. package/src/core/renderers/webgl/WebGlRenderOp.ts +1 -1
  105. package/src/core/renderers/webgl/WebGlRenderer.ts +12 -13
  106. package/src/core/renderers/webgl/WebGlShaderProgram.ts +2 -2
  107. package/src/core/shaders/canvas/Border.ts +4 -4
  108. package/src/core/shaders/canvas/HolePunch.ts +4 -11
  109. package/src/core/shaders/canvas/LinearGradient.ts +2 -2
  110. package/src/core/shaders/canvas/RadialGradient.ts +4 -4
  111. package/src/core/shaders/canvas/Rounded.ts +2 -2
  112. package/src/core/shaders/canvas/RoundedWithBorder.ts +4 -6
  113. package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +4 -6
  114. package/src/core/shaders/canvas/RoundedWithShadow.ts +2 -2
  115. package/src/core/shaders/templates/BorderTemplate.ts +11 -11
  116. package/src/core/shaders/templates/HolePunchTemplate.ts +4 -4
  117. package/src/core/shaders/templates/RadialGradientTemplate.ts +4 -4
  118. package/src/core/shaders/webgl/Border.ts +1 -1
  119. package/src/core/shaders/webgl/HolePunch.ts +2 -2
  120. package/src/core/shaders/webgl/RadialGradient.ts +3 -3
  121. package/src/core/shaders/webgl/Rounded.ts +1 -5
  122. package/src/core/shaders/webgl/RoundedWithBorder.ts +2 -6
  123. package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +2 -2
  124. package/src/core/shaders/webgl/RoundedWithShadow.ts +1 -5
  125. package/src/core/textures/ColorTexture.ts +1 -1
  126. package/src/core/textures/ImageTexture.ts +15 -15
  127. package/src/core/textures/NoiseTexture.ts +8 -8
  128. package/src/core/textures/RenderTexture.ts +12 -12
  129. package/src/core/textures/SubTexture.ts +10 -10
  130. package/src/core/textures/Texture.ts +7 -7
  131. package/src/main-api/Inspector.ts +8 -8
  132. package/src/main-api/Renderer.ts +2 -2
@@ -96,7 +96,7 @@ export class WebGlCtxTexture extends CoreContextTexture {
96
96
  }
97
97
 
98
98
  try {
99
- const { width, height } = await this.onLoadRequest();
99
+ const { w, h } = await this.onLoadRequest();
100
100
 
101
101
  // If the texture has been freed while loading, return early.
102
102
  // Type assertion needed because state could change during async operations
@@ -105,11 +105,11 @@ export class WebGlCtxTexture extends CoreContextTexture {
105
105
  }
106
106
 
107
107
  this.state = 'loaded';
108
- this._w = width;
109
- this._h = height;
108
+ this._w = w;
109
+ this._h = h;
110
110
  // Update the texture source's width and height so that it can be used
111
111
  // for rendering.
112
- this.textureSource.setState('loaded', { width, height });
112
+ this.textureSource.setState('loaded', { w, h });
113
113
 
114
114
  // cleanup source texture data next tick
115
115
  // This is done using queueMicrotask to ensure it runs after the current
@@ -152,8 +152,8 @@ export class WebGlCtxTexture extends CoreContextTexture {
152
152
  glw.texImage2D(0, glw.RGBA, 1, 1, 0, glw.RGBA, glw.UNSIGNED_BYTE, null);
153
153
  this.setTextureMemUse(TRANSPARENT_TEXTURE_DATA.byteLength);
154
154
 
155
- let width = 0;
156
- let height = 0;
155
+ let w = 0;
156
+ let h = 0;
157
157
 
158
158
  glw.activeTexture(0);
159
159
 
@@ -167,11 +167,11 @@ export class WebGlCtxTexture extends CoreContextTexture {
167
167
  if (
168
168
  (typeof ImageBitmap !== 'undefined' && tdata instanceof ImageBitmap) ||
169
169
  tdata instanceof ImageData ||
170
- // not using typeof HTMLImageElement due to web worker
171
- isHTMLImageElement(tdata)
170
+ // not using typeof HTMLI mageElement due to web worker
171
+ isHTMLImageElement(tdata) === true
172
172
  ) {
173
- width = tdata.width;
174
- height = tdata.height;
173
+ w = tdata.width;
174
+ h = tdata.height;
175
175
  glw.bindTexture(this._nativeCtxTexture);
176
176
  glw.pixelStorei(
177
177
  glw.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
@@ -180,10 +180,10 @@ export class WebGlCtxTexture extends CoreContextTexture {
180
180
 
181
181
  glw.texImage2D(0, format, format, glw.UNSIGNED_BYTE, tdata);
182
182
 
183
- this.setTextureMemUse(height * width * formatBytes * memoryPadding);
183
+ this.setTextureMemUse(h * w * formatBytes * memoryPadding);
184
184
  } else if (tdata === null) {
185
- width = 0;
186
- height = 0;
185
+ w = 0;
186
+ h = 0;
187
187
  // Reset to a 1x1 transparent texture
188
188
  glw.bindTexture(this._nativeCtxTexture);
189
189
 
@@ -199,7 +199,7 @@ export class WebGlCtxTexture extends CoreContextTexture {
199
199
  );
200
200
  this.setTextureMemUse(TRANSPARENT_TEXTURE_DATA.byteLength);
201
201
  } else if ('mipmaps' in tdata && tdata.mipmaps) {
202
- const { mipmaps, width = 0, height = 0, type, glInternalFormat } = tdata;
202
+ const { mipmaps, w = 0, h = 0, type, glInternalFormat } = tdata;
203
203
  const view =
204
204
  type === 'ktx'
205
205
  ? new DataView(mipmaps[0] ?? new ArrayBuffer(0))
@@ -207,7 +207,7 @@ export class WebGlCtxTexture extends CoreContextTexture {
207
207
 
208
208
  glw.bindTexture(this._nativeCtxTexture);
209
209
 
210
- glw.compressedTexImage2D(0, glInternalFormat, width, height, 0, view);
210
+ glw.compressedTexImage2D(0, glInternalFormat, w, h, 0, view);
211
211
  glw.texParameteri(glw.TEXTURE_WRAP_S, glw.CLAMP_TO_EDGE);
212
212
  glw.texParameteri(glw.TEXTURE_WRAP_T, glw.CLAMP_TO_EDGE);
213
213
  glw.texParameteri(glw.TEXTURE_MAG_FILTER, glw.LINEAR);
@@ -216,8 +216,8 @@ export class WebGlCtxTexture extends CoreContextTexture {
216
216
  this.setTextureMemUse(view.byteLength);
217
217
  } else if (tdata && tdata instanceof Uint8Array) {
218
218
  // Color Texture
219
- width = 1;
220
- height = 1;
219
+ w = 1;
220
+ h = 1;
221
221
 
222
222
  glw.bindTexture(this._nativeCtxTexture);
223
223
  glw.pixelStorei(
@@ -225,18 +225,9 @@ export class WebGlCtxTexture extends CoreContextTexture {
225
225
  !!textureData.premultiplyAlpha,
226
226
  );
227
227
 
228
- glw.texImage2D(
229
- 0,
230
- format,
231
- width,
232
- height,
233
- 0,
234
- format,
235
- glw.UNSIGNED_BYTE,
236
- tdata,
237
- );
228
+ glw.texImage2D(0, format, w, h, 0, format, glw.UNSIGNED_BYTE, tdata);
238
229
 
239
- this.setTextureMemUse(width * height * formatBytes);
230
+ this.setTextureMemUse(w * h * formatBytes);
240
231
  } else {
241
232
  console.error(
242
233
  `WebGlCoreCtxTexture.onLoadRequest: Unexpected textureData returned`,
@@ -245,8 +236,8 @@ export class WebGlCtxTexture extends CoreContextTexture {
245
236
  }
246
237
 
247
238
  return {
248
- width,
249
- height,
239
+ w,
240
+ h,
250
241
  };
251
242
  }
252
243
 
@@ -139,7 +139,7 @@ export class WebGlRenderOp extends CoreRenderOp {
139
139
  // to be relative to the parent's framebuffer
140
140
  if (this.parentHasRenderTexture) {
141
141
  clipY = this.framebufferDimensions
142
- ? this.framebufferDimensions.height - this.height
142
+ ? this.framebufferDimensions.h - this.height
143
143
  : 0;
144
144
  }
145
145
 
@@ -663,13 +663,12 @@ export class WebGlRenderer extends CoreRenderer {
663
663
 
664
664
  if (texture.type === TextureType.subTexture) {
665
665
  const props = (texture as SubTexture).props;
666
- const { width: parentW = 0, height: parentH = 0 } = (
667
- texture as SubTexture
668
- ).parentTexture.dimensions || { width: 0, height: 0 };
666
+ const { w: parentW = 0, h: parentH = 0 } = (texture as SubTexture)
667
+ .parentTexture.dimensions || { w: 0, h: 0 };
669
668
  result.x1 = props.x / parentW;
670
- result.x2 = result.x1 + props.width / parentW;
669
+ result.x2 = result.x1 + props.w / parentW;
671
670
  result.y1 = props.y / parentH;
672
- result.y2 = result.y1 + props.height / parentH;
671
+ result.y2 = result.y1 + props.h / parentH;
673
672
  }
674
673
 
675
674
  if (
@@ -681,23 +680,23 @@ export class WebGlRenderer extends CoreRenderer {
681
680
  const resizeMode = textureOptions.resizeMode;
682
681
  const dimensions = texture.dimensions;
683
682
  if (resizeMode.type === 'cover') {
684
- const scaleX = node.props.width / dimensions.width;
685
- const scaleY = node.props.height / dimensions.height;
683
+ const scaleX = node.props.w / dimensions.w;
684
+ const scaleY = node.props.h / dimensions.h;
686
685
  const scale = Math.max(scaleX, scaleY);
687
686
  const precision = 1 / scale;
688
687
  // Determine based on width
689
688
  if (scaleX < scale) {
690
- const desiredSize = precision * node.props.width;
689
+ const desiredSize = precision * node.props.w;
691
690
  result.x1 =
692
- (1 - desiredSize / dimensions.width) * (resizeMode.clipX ?? 0.5);
693
- result.x2 = result.x1 + desiredSize / dimensions.width;
691
+ (1 - desiredSize / dimensions.w) * (resizeMode.clipX ?? 0.5);
692
+ result.x2 = result.x1 + desiredSize / dimensions.w;
694
693
  }
695
694
  // Determine based on height
696
695
  if (scaleY < scale) {
697
- const desiredSize = precision * node.props.height;
696
+ const desiredSize = precision * node.props.h;
698
697
  result.y1 =
699
- (1 - desiredSize / dimensions.height) * (resizeMode.clipY ?? 0.5);
700
- result.y2 = result.y1 + desiredSize / dimensions.height;
698
+ (1 - desiredSize / dimensions.h) * (resizeMode.clipY ?? 0.5);
699
+ result.y2 = result.y1 + desiredSize / dimensions.h;
701
700
  }
702
701
  }
703
702
  }
@@ -206,13 +206,13 @@ export class WebGlShaderProgram implements CoreShaderProgram {
206
206
  // Bind render texture framebuffer dimensions as resolution
207
207
  // if the parent has a render texture
208
208
  if (parentHasRenderTexture === true) {
209
- const { width, height } = renderOp.framebufferDimensions!;
209
+ const { w, h } = renderOp.framebufferDimensions!;
210
210
  // Force pixel ratio to 1.0 for render textures since they are always 1:1
211
211
  // the final render texture will be rendered to the screen with the correct pixel ratio
212
212
  this.glw.uniform1f('u_pixelRatio', 1.0);
213
213
 
214
214
  // Set resolution to the framebuffer dimensions
215
- this.glw.uniform2f('u_resolution', width, height);
215
+ this.glw.uniform2f('u_resolution', w, h);
216
216
  } else {
217
217
  this.glw.uniform1f('u_pixelRatio', renderOp.renderer.stage.pixelRatio);
218
218
  this.glw.uniform2f(
@@ -35,13 +35,13 @@ export const Border: CanvasShaderType<BorderProps, ComputedBorderValues> = {
35
35
  props: BorderTemplate.props,
36
36
  update() {
37
37
  this.computed.borderColor = formatRgba(parseColorRgba(this.props!.color));
38
- this.computed.borderAsym = !valuesAreEqual(this.props!.width as number[]);
38
+ this.computed.borderAsym = !valuesAreEqual(this.props!.w as number[]);
39
39
  },
40
40
  render(ctx, quad, renderContext) {
41
41
  renderContext();
42
42
  ctx.strokeStyle = this.computed.borderColor!;
43
- if (this.computed.borderAsym === false && this.props!.width[0] > 0) {
44
- const bWidth = this.props!.width[0];
43
+ if (this.computed.borderAsym === false && this.props!.w[0] > 0) {
44
+ const bWidth = this.props!.w[0];
45
45
  const bHalfWidth = bWidth * 0.5;
46
46
  ctx.lineWidth = bWidth;
47
47
  ctx.beginPath();
@@ -54,7 +54,7 @@ export const Border: CanvasShaderType<BorderProps, ComputedBorderValues> = {
54
54
  return;
55
55
  }
56
56
 
57
- const { 0: t, 1: r, 2: b, 3: l } = this.props!.width as Vec4;
57
+ const { 0: t, 1: r, 2: b, 3: l } = this.props!.w as Vec4;
58
58
  if (t > 0) {
59
59
  const y = quad.ty + t * 0.5;
60
60
  strokeLine(ctx, quad.tx, y, quad.tx + quad.width, y, t);
@@ -36,23 +36,16 @@ export const HolePunch: CanvasShaderType<
36
36
  update() {
37
37
  this.computed.radius = calcFactoredRadiusArray(
38
38
  this.props!.radius as Vec4,
39
- this.props!.width,
40
- this.props!.height,
39
+ this.props!.w,
40
+ this.props!.h,
41
41
  );
42
42
  },
43
43
  render(ctx, quad, renderContext) {
44
44
  ctx.save();
45
45
  renderContext();
46
- const { x, y, width, height } = this.props!;
46
+ const { x, y, w, h } = this.props!;
47
47
  ctx.beginPath();
48
- roundRect(
49
- ctx,
50
- quad.tx + x,
51
- quad.ty + y,
52
- width,
53
- height,
54
- this.computed.radius!,
55
- );
48
+ roundRect(ctx, quad.tx + x, quad.ty + y, w, h, this.computed.radius!);
56
49
  ctx.closePath();
57
50
  ctx.fillStyle = 'black';
58
51
  ctx.globalCompositeOperation = 'destination-out';
@@ -36,8 +36,8 @@ export const LinearGradient: CanvasShaderType<
36
36
  props: LinearGradientTemplate.props,
37
37
  update(node) {
38
38
  const angle = this.props!.angle - (Math.PI / 180) * 90;
39
- const nWidth = node.width;
40
- const nHeight = node.height;
39
+ const nWidth = node.w;
40
+ const nHeight = node.h;
41
41
  const line =
42
42
  (Math.abs(nWidth * Math.sin(angle)) +
43
43
  Math.abs(nHeight * Math.cos(angle))) *
@@ -39,8 +39,8 @@ export const RadialGradient: CanvasShaderType<
39
39
  let scaleX = 1;
40
40
  let scaleY = 1;
41
41
  const props = this.props as RadialGradientProps;
42
- const pWidth = props.width;
43
- const pHeight = props.height;
42
+ const pWidth = props.w;
43
+ const pHeight = props.h;
44
44
  if (pWidth > pHeight) {
45
45
  scaleX = pWidth / pHeight;
46
46
  } else if (pHeight > pWidth) {
@@ -48,8 +48,8 @@ export const RadialGradient: CanvasShaderType<
48
48
  }
49
49
 
50
50
  this.computed = {
51
- pivotX: props.pivot[0] * node.width,
52
- pivotY: props.pivot[1] * node.height,
51
+ pivotX: props.pivot[0] * node.w,
52
+ pivotY: props.pivot[1] * node.h,
53
53
  scaleX,
54
54
  scaleY,
55
55
  size: Math.min(pWidth, pHeight) * 0.5,
@@ -34,8 +34,8 @@ export const Rounded: CanvasShaderType<RoundedProps, ComputedRoundedValues> = {
34
34
  update(node) {
35
35
  this.computed.radius = calcFactoredRadiusArray(
36
36
  this.props!.radius as Vec4,
37
- node.width,
38
- node.height,
37
+ node.w,
38
+ node.h,
39
39
  );
40
40
  },
41
41
  render(ctx, quad, renderContext) {
@@ -38,16 +38,14 @@ export const RoundedWithBorder: CanvasShaderType<
38
38
  const props = this.props!;
39
39
  const radius = calcFactoredRadiusArray(
40
40
  props.radius as Vec4,
41
- node.width,
42
- node.height,
41
+ node.w,
42
+ node.h,
43
43
  );
44
44
  this.computed.radius = radius;
45
45
  this.computed.borderColor = this.toColorString(props['border-color']);
46
- this.computed.borderAsym = !valuesAreEqual(
47
- props['border-width'] as number[],
48
- );
46
+ this.computed.borderAsym = !valuesAreEqual(props['border-w'] as number[]);
49
47
  //following vec4 convention 0, 1, 2, 3 => x, y, z, w;
50
- const [x, y, z, w] = props['border-width'] as Vec4;
48
+ const [x, y, z, w] = props['border-w'] as Vec4;
51
49
  this.computed.borderRadius = [
52
50
  Math.max(0.0, radius[0] - Math.max(x, w) * 0.5),
53
51
  Math.max(0.0, radius[1] - Math.max(x, y) * 0.5),
@@ -41,15 +41,13 @@ export const RoundedWithBorderAndShadow: CanvasShaderType<
41
41
  const props = this.props!;
42
42
  const radius = calcFactoredRadiusArray(
43
43
  props.radius as Vec4,
44
- node.width,
45
- node.height,
44
+ node.w,
45
+ node.h,
46
46
  );
47
47
  this.computed.radius = radius;
48
48
  this.computed.borderColor = this.toColorString(props['border-color']);
49
- this.computed.borderAsym = !valuesAreEqual(
50
- props['border-width'] as number[],
51
- );
52
- const borderWidth = props['border-width'] as Vec4;
49
+ this.computed.borderAsym = !valuesAreEqual(props['border-w'] as number[]);
50
+ const borderWidth = props['border-w'] as Vec4;
53
51
  this.computed.borderRadius = radius.map((value, index) =>
54
52
  Math.max(0, value - borderWidth[index]! * 0.5),
55
53
  ) as Vec4;
@@ -38,8 +38,8 @@ export const RoundedWithShadow: CanvasShaderType<
38
38
  const props = this.props!;
39
39
  const radius = calcFactoredRadiusArray(
40
40
  props.radius as Vec4,
41
- node.width,
42
- node.height,
41
+ node.w,
42
+ node.h,
43
43
  );
44
44
  this.computed.radius = radius;
45
45
  this.computed.shadowColor = this.toColorString(props['shadow-color']);
@@ -28,7 +28,7 @@ export interface BorderProps {
28
28
  *
29
29
  * @default 0
30
30
  */
31
- width: number | [number, number, number, number];
31
+ w: number | [number, number, number, number];
32
32
  /**
33
33
  * Color of the border in 0xRRGGBBAA
34
34
  *
@@ -57,9 +57,9 @@ export function getBorderProps<P extends string>(
57
57
  prefix?: P,
58
58
  ): PrefixedType<BorderProps, P> {
59
59
  const pf = prefix && prefix.length > 0 ? `${prefix}-` : '';
60
- const width = pf + 'width';
60
+ const w = pf + 'w';
61
61
  return {
62
- [width]: {
62
+ [w]: {
63
63
  default: [0, 0, 0, 0],
64
64
  resolve(value) {
65
65
  if (value !== undefined) {
@@ -72,37 +72,37 @@ export function getBorderProps<P extends string>(
72
72
  [pf + 'top']: {
73
73
  default: 0,
74
74
  set(value, props) {
75
- (props[width] as Vec4)[0] = value;
75
+ (props[w] as Vec4)[0] = value;
76
76
  },
77
77
  get(props) {
78
- return (props[width] as Vec4)[0];
78
+ return (props[w] as Vec4)[0];
79
79
  },
80
80
  },
81
81
  [pf + 'right']: {
82
82
  default: 0,
83
83
  set(value, props) {
84
- (props[width] as Vec4)[1] = value;
84
+ (props[w] as Vec4)[1] = value;
85
85
  },
86
86
  get(props) {
87
- return (props[width] as Vec4)[1];
87
+ return (props[w] as Vec4)[1];
88
88
  },
89
89
  },
90
90
  [pf + 'bottom']: {
91
91
  default: 0,
92
92
  set(value, props) {
93
- (props[width] as Vec4)[2] = value;
93
+ (props[w] as Vec4)[2] = value;
94
94
  },
95
95
  get(props) {
96
- return (props[width] as Vec4)[2];
96
+ return (props[w] as Vec4)[2];
97
97
  },
98
98
  },
99
99
  [pf + 'left']: {
100
100
  default: 0,
101
101
  set(value, props) {
102
- (props[width] as Vec4)[3] = value;
102
+ (props[w] as Vec4)[3] = value;
103
103
  },
104
104
  get(props) {
105
- return (props[width] as Vec4)[3];
105
+ return (props[w] as Vec4)[3];
106
106
  },
107
107
  },
108
108
  } as PrefixedType<BorderProps, P>;
@@ -33,13 +33,13 @@ export interface HolePunchProps {
33
33
  /**
34
34
  * Width of the hole punch
35
35
  */
36
- width: number;
36
+ w: number;
37
37
  /**
38
38
  * height of the hole punch
39
39
  *
40
40
  * @remarks if not defined uses the width value
41
41
  */
42
- height: number;
42
+ h: number;
43
43
  /**
44
44
  * Corner radius in pixels, to cut out of the corners of the hole punch
45
45
  *
@@ -67,8 +67,8 @@ export const HolePunchTemplate: CoreShaderType<HolePunchProps> = {
67
67
  props: {
68
68
  x: 0,
69
69
  y: 0,
70
- width: 50,
71
- height: 50,
70
+ w: 50,
71
+ h: 50,
72
72
  radius: {
73
73
  default: [0, 0, 0, 0],
74
74
  resolve(value) {
@@ -34,13 +34,13 @@ export interface RadialGradientProps {
34
34
  /**
35
35
  * Width of the RadialGradientEffect
36
36
  */
37
- width: number;
37
+ w: number;
38
38
  /**
39
39
  * height of the RadialGradientEffect
40
40
  *
41
41
  * @remarks if not defined uses the width value
42
42
  */
43
- height: number;
43
+ h: number;
44
44
  /**
45
45
  * center point of where the RadialGradientEffect is drawn
46
46
  */
@@ -74,8 +74,8 @@ export const RadialGradientTemplate: CoreShaderType<RadialGradientProps> = {
74
74
  return value;
75
75
  },
76
76
  },
77
- width: 50,
78
- height: 50,
77
+ w: 50,
78
+ h: 50,
79
79
  pivot: [0.5, 0.5],
80
80
  },
81
81
  };
@@ -26,7 +26,7 @@ import type { WebGlShaderType } from '../../renderers/webgl/WebGlShaderNode.js';
26
26
  export const Border: WebGlShaderType<BorderProps> = {
27
27
  props: BorderTemplate.props,
28
28
  update(node) {
29
- this.uniform4fa('u_borderWidth', this.props!.width as Vec4);
29
+ this.uniform4fa('u_borderWidth', this.props!.w as Vec4);
30
30
  this.uniformRGBA('u_borderColor', this.props!.color);
31
31
  },
32
32
  vertex: `
@@ -29,11 +29,11 @@ export const HolePunch: WebGlShaderType<HolePunchProps> = {
29
29
  const props = this.props!;
30
30
  this.uniform2f('u_pos', props.x, props.y);
31
31
  //precalculate to halfSize once instead of for every pixel
32
- this.uniform2f('u_size', props.width * 0.5, props.height * 0.5);
32
+ this.uniform2f('u_size', props.w * 0.5, props.h * 0.5);
33
33
 
34
34
  this.uniform4fa(
35
35
  'u_radius',
36
- calcFactoredRadiusArray(props.radius as Vec4, props.width, props.height),
36
+ calcFactoredRadiusArray(props.radius as Vec4, props.w, props.h),
37
37
  );
38
38
  },
39
39
  getCacheMarkers(props: HolePunchProps) {
@@ -31,10 +31,10 @@ export const RadialGradient: WebGlShaderType<RadialGradientProps> = {
31
31
  const props = this.props!;
32
32
  this.uniform2f(
33
33
  'u_projection',
34
- props.pivot[0] * node.width,
35
- props.pivot[1] * node.height,
34
+ props.pivot[0] * node.w,
35
+ props.pivot[1] * node.h,
36
36
  );
37
- this.uniform2f('u_size', props.width * 0.5, props.height * 0.5);
37
+ this.uniform2f('u_size', props.w * 0.5, props.h * 0.5);
38
38
  this.uniform1fv('u_stops', new Float32Array(props.stops));
39
39
  const colors: number[] = [];
40
40
  for (let i = 0; i < props.colors.length; i++) {
@@ -34,11 +34,7 @@ export const Rounded: WebGlShaderType<RoundedProps> = {
34
34
  update(node: CoreNode) {
35
35
  this.uniform4fa(
36
36
  'u_radius',
37
- calcFactoredRadiusArray(
38
- this.props!.radius as Vec4,
39
- node.width,
40
- node.height,
41
- ),
37
+ calcFactoredRadiusArray(this.props!.radius as Vec4, node.w, node.h),
42
38
  );
43
39
  },
44
40
  vertex: `
@@ -28,15 +28,11 @@ export const RoundedWithBorder: WebGlShaderType<RoundedWithBorderProps> = {
28
28
  props: RoundedWithBorderTemplate.props,
29
29
  update(node: CoreNode) {
30
30
  this.uniformRGBA('u_borderColor', this.props!['border-color']);
31
- this.uniform4fa('u_borderWidth', this.props!['border-width'] as Vec4);
31
+ this.uniform4fa('u_borderWidth', this.props!['border-w'] as Vec4);
32
32
 
33
33
  this.uniform4fa(
34
34
  'u_radius',
35
- calcFactoredRadiusArray(
36
- this.props!.radius as Vec4,
37
- node.width,
38
- node.height,
39
- ),
35
+ calcFactoredRadiusArray(this.props!.radius as Vec4, node.w, node.h),
40
36
  );
41
37
  },
42
38
  vertex: `
@@ -30,14 +30,14 @@ export const RoundedWithBorderAndShadow: WebGlShaderType<RoundedWithBorderAndSha
30
30
  update(node: CoreNode) {
31
31
  const props = this.props!;
32
32
  this.uniformRGBA('u_borderColor', props['border-color']);
33
- this.uniform4fa('u_borderWidth', props['border-width'] as Vec4);
33
+ this.uniform4fa('u_borderWidth', props['border-w'] as Vec4);
34
34
 
35
35
  this.uniformRGBA('u_shadowColor', props['shadow-color']);
36
36
  this.uniform4fa('u_shadow', props['shadow-projection']);
37
37
 
38
38
  this.uniform4fa(
39
39
  'u_radius',
40
- calcFactoredRadiusArray(props.radius as Vec4, node.width, node.height),
40
+ calcFactoredRadiusArray(props.radius as Vec4, node.w, node.h),
41
41
  );
42
42
  },
43
43
  vertex: `
@@ -32,11 +32,7 @@ export const RoundedWithShadow: WebGlShaderType<RoundedWithShadowProps> = {
32
32
  this.uniform4fa('u_shadow', this.props!['shadow-projection']!);
33
33
  this.uniform4fa(
34
34
  'u_radius',
35
- calcFactoredRadiusArray(
36
- this.props!.radius as Vec4,
37
- node.width,
38
- node.height,
39
- ),
35
+ calcFactoredRadiusArray(this.props!.radius as Vec4, node.w, node.h),
40
36
  );
41
37
  },
42
38
  vertex: Shadow.vertex as string,
@@ -77,7 +77,7 @@ export class ColorTexture extends Texture {
77
77
  pixelData[3] = (this.color >>> 24) & 0xff; // Alpha
78
78
  }
79
79
 
80
- this.setState('fetched', { width: 1, height: 1 });
80
+ this.setState('fetched', { w: 1, h: 1 });
81
81
 
82
82
  return {
83
83
  data: pixelData,