@lightningjs/renderer 2.13.0 → 2.13.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.
Files changed (155) hide show
  1. package/dist/exports/canvas-shaders.d.ts +10 -0
  2. package/dist/exports/canvas-shaders.js +27 -0
  3. package/dist/exports/canvas-shaders.js.map +1 -0
  4. package/dist/exports/webgl-shaders.d.ts +11 -0
  5. package/dist/exports/webgl-shaders.js +28 -0
  6. package/dist/exports/webgl-shaders.js.map +1 -0
  7. package/dist/src/core/lib/ImageWorker.js +2 -1
  8. package/dist/src/core/lib/ImageWorker.js.map +1 -1
  9. package/dist/src/core/lib/utils.d.ts +4 -0
  10. package/dist/src/core/lib/utils.js +46 -0
  11. package/dist/src/core/lib/utils.js.map +1 -1
  12. package/dist/src/core/renderers/CoreShaderNode.d.ts +59 -0
  13. package/dist/src/core/renderers/CoreShaderNode.js +107 -0
  14. package/dist/src/core/renderers/CoreShaderNode.js.map +1 -0
  15. package/dist/src/core/renderers/CoreShaderProgram.d.ts +4 -0
  16. package/dist/src/core/renderers/CoreShaderProgram.js +20 -0
  17. package/dist/src/core/renderers/CoreShaderProgram.js.map +1 -0
  18. package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +36 -0
  19. package/dist/src/core/renderers/canvas/CanvasRenderer.js +212 -0
  20. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -0
  21. package/dist/src/core/renderers/canvas/CanvasShaderNode.d.ts +21 -0
  22. package/dist/src/core/renderers/canvas/CanvasShaderNode.js +60 -0
  23. package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +1 -0
  24. package/dist/src/core/renderers/canvas/CanvasTexture.d.ts +16 -0
  25. package/dist/src/core/renderers/canvas/CanvasTexture.js +123 -0
  26. package/dist/src/core/renderers/canvas/CanvasTexture.js.map +1 -0
  27. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.d.ts +12 -0
  28. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +55 -0
  29. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -0
  30. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +9 -0
  31. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +38 -0
  32. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -0
  33. package/dist/src/core/renderers/webgl/WebGlCtxTexture.d.ts +57 -0
  34. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +227 -0
  35. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -0
  36. package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +36 -0
  37. package/dist/src/core/renderers/webgl/WebGlRenderOp.js +107 -0
  38. package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +1 -0
  39. package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +134 -0
  40. package/dist/src/core/renderers/webgl/WebGlRenderer.js +546 -0
  41. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -0
  42. package/dist/src/core/renderers/webgl/WebGlShaderNode.d.ts +221 -0
  43. package/dist/src/core/renderers/webgl/WebGlShaderNode.js +334 -0
  44. package/dist/src/core/renderers/webgl/WebGlShaderNode.js.map +1 -0
  45. package/dist/src/core/renderers/webgl/WebGlShaderProgram.d.ts +35 -0
  46. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +195 -0
  47. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -0
  48. package/dist/src/core/shaders/canvas/Border.d.ts +9 -0
  49. package/dist/src/core/shaders/canvas/Border.js +57 -0
  50. package/dist/src/core/shaders/canvas/Border.js.map +1 -0
  51. package/dist/src/core/shaders/canvas/HolePunch.d.ts +7 -0
  52. package/dist/src/core/shaders/canvas/HolePunch.js +38 -0
  53. package/dist/src/core/shaders/canvas/HolePunch.js.map +1 -0
  54. package/dist/src/core/shaders/canvas/LinearGradient.d.ts +10 -0
  55. package/dist/src/core/shaders/canvas/LinearGradient.js +46 -0
  56. package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -0
  57. package/dist/src/core/shaders/canvas/RadialGradient.d.ts +11 -0
  58. package/dist/src/core/shaders/canvas/RadialGradient.js +68 -0
  59. package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -0
  60. package/dist/src/core/shaders/canvas/Rounded.d.ts +7 -0
  61. package/dist/src/core/shaders/canvas/Rounded.js +33 -0
  62. package/dist/src/core/shaders/canvas/Rounded.js.map +1 -0
  63. package/dist/src/core/shaders/canvas/RoundedWithBorder.d.ts +7 -0
  64. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +35 -0
  65. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -0
  66. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.d.ts +8 -0
  67. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +39 -0
  68. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -0
  69. package/dist/src/core/shaders/canvas/RoundedWithShadow.d.ts +7 -0
  70. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +38 -0
  71. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -0
  72. package/dist/src/core/shaders/canvas/Shadow.d.ts +8 -0
  73. package/dist/src/core/shaders/canvas/Shadow.js +31 -0
  74. package/dist/src/core/shaders/canvas/Shadow.js.map +1 -0
  75. package/dist/src/core/shaders/canvas/utils/render.d.ts +5 -0
  76. package/dist/src/core/shaders/canvas/utils/render.js +84 -0
  77. package/dist/src/core/shaders/canvas/utils/render.js.map +1 -0
  78. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +37 -0
  79. package/dist/src/core/shaders/templates/BorderTemplate.js +73 -0
  80. package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -0
  81. package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +46 -0
  82. package/dist/src/core/shaders/templates/HolePunchTemplate.js +35 -0
  83. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -0
  84. package/dist/src/core/shaders/templates/LinearGradientTemplate.d.ts +23 -0
  85. package/dist/src/core/shaders/templates/LinearGradientTemplate.js +47 -0
  86. package/dist/src/core/shaders/templates/LinearGradientTemplate.js.map +1 -0
  87. package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +31 -0
  88. package/dist/src/core/shaders/templates/RadialGradientTemplate.js +49 -0
  89. package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +1 -0
  90. package/dist/src/core/shaders/templates/RoundedTemplate.d.ts +29 -0
  91. package/dist/src/core/shaders/templates/RoundedTemplate.js +67 -0
  92. package/dist/src/core/shaders/templates/RoundedTemplate.js.map +1 -0
  93. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.d.ts +7 -0
  94. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js +24 -0
  95. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js.map +1 -0
  96. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.d.ts +6 -0
  97. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js +23 -0
  98. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js.map +1 -0
  99. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.d.ts +6 -0
  100. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js +23 -0
  101. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js.map +1 -0
  102. package/dist/src/core/shaders/templates/ShadowTemplate.d.ts +34 -0
  103. package/dist/src/core/shaders/templates/ShadowTemplate.js +66 -0
  104. package/dist/src/core/shaders/templates/ShadowTemplate.js.map +1 -0
  105. package/dist/src/core/shaders/templates/shaderUtils.d.ts +5 -0
  106. package/dist/src/core/shaders/templates/shaderUtils.js +41 -0
  107. package/dist/src/core/shaders/templates/shaderUtils.js.map +1 -0
  108. package/dist/src/core/shaders/webgl/Border.d.ts +3 -0
  109. package/dist/src/core/shaders/webgl/Border.js +87 -0
  110. package/dist/src/core/shaders/webgl/Border.js.map +1 -0
  111. package/dist/src/core/shaders/webgl/Default.d.ts +2 -0
  112. package/dist/src/core/shaders/webgl/Default.js +86 -0
  113. package/dist/src/core/shaders/webgl/Default.js.map +1 -0
  114. package/dist/src/core/shaders/webgl/DefaultBatched.d.ts +2 -0
  115. package/dist/src/core/shaders/webgl/DefaultBatched.js +104 -0
  116. package/dist/src/core/shaders/webgl/DefaultBatched.js.map +1 -0
  117. package/dist/src/core/shaders/webgl/HolePunch.d.ts +3 -0
  118. package/dist/src/core/shaders/webgl/HolePunch.js +64 -0
  119. package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -0
  120. package/dist/src/core/shaders/webgl/LinearGradient.d.ts +3 -0
  121. package/dist/src/core/shaders/webgl/LinearGradient.js +75 -0
  122. package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -0
  123. package/dist/src/core/shaders/webgl/RadialGradient.d.ts +3 -0
  124. package/dist/src/core/shaders/webgl/RadialGradient.js +73 -0
  125. package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -0
  126. package/dist/src/core/shaders/webgl/Rounded.d.ts +7 -0
  127. package/dist/src/core/shaders/webgl/Rounded.js +86 -0
  128. package/dist/src/core/shaders/webgl/Rounded.js.map +1 -0
  129. package/dist/src/core/shaders/webgl/RoundedWithBorder.d.ts +3 -0
  130. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +97 -0
  131. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -0
  132. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.d.ts +3 -0
  133. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +112 -0
  134. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -0
  135. package/dist/src/core/shaders/webgl/RoundedWithShadow.d.ts +3 -0
  136. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +84 -0
  137. package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +1 -0
  138. package/dist/src/core/shaders/webgl/SdfShader.d.ts +32 -0
  139. package/dist/src/core/shaders/webgl/SdfShader.js +116 -0
  140. package/dist/src/core/shaders/webgl/SdfShader.js.map +1 -0
  141. package/dist/src/core/shaders/webgl/Shadow.d.ts +3 -0
  142. package/dist/src/core/shaders/webgl/Shadow.js +110 -0
  143. package/dist/src/core/shaders/webgl/Shadow.js.map +1 -0
  144. package/dist/src/core/textures/ImageTexture.d.ts +2 -2
  145. package/dist/src/core/textures/ImageTexture.js +24 -4
  146. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  147. package/dist/src/core/textures/Texture.d.ts +4 -2
  148. package/dist/src/core/textures/Texture.js +18 -6
  149. package/dist/src/core/textures/Texture.js.map +1 -1
  150. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  151. package/package.json +1 -1
  152. package/src/core/lib/ImageWorker.ts +2 -1
  153. package/src/core/lib/utils.ts +74 -0
  154. package/src/core/textures/ImageTexture.ts +31 -8
  155. package/src/core/textures/Texture.ts +23 -7
@@ -0,0 +1,195 @@
1
+ import { Default } from '../../shaders/webgl/Default.js';
2
+ import { createProgram, createShader, } from './internal/ShaderUtils.js';
3
+ export class WebGlShaderProgram {
4
+ boundBufferCollection = null;
5
+ program;
6
+ /**
7
+ * Vertex Array Object
8
+ *
9
+ * @remarks
10
+ * Used by WebGL2 Only
11
+ */
12
+ vao;
13
+ renderer;
14
+ glw;
15
+ attributeLocations;
16
+ lifecycle;
17
+ useSystemAlpha = false;
18
+ useSystemDimensions = false;
19
+ supportsIndexedTextures = false;
20
+ constructor(renderer, config, resolvedProps) {
21
+ this.renderer = renderer;
22
+ const glw = (this.glw = renderer.glw);
23
+ // Check that extensions are supported
24
+ const webGl2 = glw.isWebGl2();
25
+ let requiredExtensions = [];
26
+ this.supportsIndexedTextures =
27
+ config.supportsIndexedTextures || this.supportsIndexedTextures;
28
+ requiredExtensions =
29
+ (webGl2 && config.webgl2Extensions) ||
30
+ (!webGl2 && config.webgl1Extensions) ||
31
+ [];
32
+ const glVersion = webGl2 ? '2.0' : '1.0';
33
+ requiredExtensions.forEach((extensionName) => {
34
+ if (!glw.getExtension(extensionName)) {
35
+ throw new Error(`Shader "${this.constructor.name}" requires extension "${extensionName}" for WebGL ${glVersion} but wasn't found`);
36
+ }
37
+ });
38
+ let vertexSource = config.vertex instanceof Function
39
+ ? config.vertex(renderer, resolvedProps)
40
+ : config.vertex;
41
+ if (vertexSource === undefined) {
42
+ vertexSource = Default.vertex;
43
+ }
44
+ const fragmentSource = config.fragment instanceof Function
45
+ ? config.fragment(renderer, resolvedProps)
46
+ : config.fragment;
47
+ const vertexShader = createShader(glw, glw.VERTEX_SHADER, vertexSource);
48
+ if (!vertexShader) {
49
+ throw new Error('Vertex shader creation failed');
50
+ }
51
+ const fragmentShader = createShader(glw, glw.FRAGMENT_SHADER, fragmentSource);
52
+ if (!fragmentShader) {
53
+ throw new Error('fragment shader creation failed');
54
+ }
55
+ const program = createProgram(glw, vertexShader, fragmentShader);
56
+ if (!program) {
57
+ throw new Error();
58
+ }
59
+ this.program = program;
60
+ this.attributeLocations = glw.getAttributeLocations(program);
61
+ this.useSystemAlpha =
62
+ this.glw.getUniformLocation(program, 'u_alpha') !== null;
63
+ this.useSystemDimensions =
64
+ this.glw.getUniformLocation(program, 'u_dimensions') !== null;
65
+ this.lifecycle = {
66
+ update: config.update,
67
+ canBatch: config.canBatch,
68
+ };
69
+ }
70
+ disableAttribute(location) {
71
+ this.glw.disableVertexAttribArray(location);
72
+ }
73
+ disableAttributes() {
74
+ const { glw } = this;
75
+ const attribs = Object.keys(this.attributeLocations);
76
+ const attribLen = attribs.length;
77
+ for (let i = 0; i < attribLen; i++) {
78
+ glw.disableVertexAttribArray(i);
79
+ }
80
+ }
81
+ reuseRenderOp(renderOpA, renderOpB) {
82
+ const lifecycleCheck = this.lifecycle.canBatch
83
+ ? this.lifecycle.canBatch(renderOpA, renderOpB)
84
+ : true;
85
+ if (!lifecycleCheck) {
86
+ return false;
87
+ }
88
+ if (this.useSystemAlpha) {
89
+ if (renderOpA.alpha !== renderOpB.alpha) {
90
+ return false;
91
+ }
92
+ }
93
+ if (this.useSystemDimensions) {
94
+ if (renderOpA.width !== renderOpB.width ||
95
+ renderOpA.height !== renderOpB.height) {
96
+ return false;
97
+ }
98
+ }
99
+ const shaderPropsA = renderOpA.shader?.getResolvedProps();
100
+ const shaderPropsB = renderOpB.shader?.getResolvedProps();
101
+ if (shaderPropsA !== undefined && shaderPropsB !== undefined) {
102
+ for (const key in shaderPropsA) {
103
+ if (shaderPropsA[key] !== shaderPropsB[key]) {
104
+ return false;
105
+ }
106
+ }
107
+ }
108
+ return true;
109
+ }
110
+ bindRenderOp(renderOp) {
111
+ this.bindBufferCollection(renderOp.buffers);
112
+ this.bindTextures(renderOp.textures);
113
+ const { parentHasRenderTexture } = renderOp.quad;
114
+ // Skip if the parent and current operation both have render textures
115
+ if (renderOp.quad.rtt && parentHasRenderTexture) {
116
+ return;
117
+ }
118
+ // Bind render texture framebuffer dimensions as resolution
119
+ // if the parent has a render texture
120
+ if (parentHasRenderTexture) {
121
+ const { width, height } = renderOp.quad.framebufferDimensions;
122
+ // Force pixel ratio to 1.0 for render textures since they are always 1:1
123
+ // the final render texture will be rendered to the screen with the correct pixel ratio
124
+ this.glw.uniform1f('u_pixelRatio', 1.0);
125
+ // Set resolution to the framebuffer dimensions
126
+ this.glw.uniform2f('u_resolution', width, height);
127
+ }
128
+ else {
129
+ this.glw.uniform1f('u_pixelRatio', renderOp.renderer.stage.pixelRatio);
130
+ this.glw.uniform2f('u_resolution', this.glw.canvas.width, this.glw.canvas.height);
131
+ }
132
+ this.glw.uniform1f('u_rtt', renderOp.quad.rtt ? 1 : 0);
133
+ if (this.useSystemAlpha) {
134
+ this.glw.uniform1f('u_alpha', renderOp.quad.alpha);
135
+ }
136
+ if (this.useSystemDimensions) {
137
+ this.glw.uniform2f('u_dimensions', renderOp.quad.width, renderOp.quad.height);
138
+ }
139
+ /**temporary fix to make sdf texts work */
140
+ if (renderOp.sdfShaderProps !== undefined) {
141
+ renderOp.shader.shaderType.onSdfBind?.call(this.glw, renderOp.sdfShaderProps);
142
+ return;
143
+ }
144
+ if (renderOp.shader.props) {
145
+ /**
146
+ * loop over all precalculated uniform types
147
+ */
148
+ for (const key in renderOp.shader.uniforms.single) {
149
+ const { method, value } = renderOp.shader.uniforms.single[key];
150
+ this.glw[method](key, value);
151
+ }
152
+ for (const key in renderOp.shader.uniforms.vec2) {
153
+ const { method, value } = renderOp.shader.uniforms.vec2[key];
154
+ this.glw[method](key, value[0], value[1]);
155
+ }
156
+ for (const key in renderOp.shader.uniforms.vec3) {
157
+ const { method, value } = renderOp.shader.uniforms.vec3[key];
158
+ this.glw[method](key, value[0], value[1], value[2]);
159
+ }
160
+ for (const key in renderOp.shader.uniforms.vec4) {
161
+ const { method, value } = renderOp.shader.uniforms.vec4[key];
162
+ this.glw[method](key, value[0], value[1], value[2], value[3]);
163
+ }
164
+ }
165
+ }
166
+ bindBufferCollection(buffer) {
167
+ const { glw } = this;
168
+ const attribs = Object.keys(this.attributeLocations);
169
+ const attribLen = attribs.length;
170
+ for (let i = 0; i < attribLen; i++) {
171
+ const name = attribs[i];
172
+ const resolvedBuffer = buffer.getBuffer(name);
173
+ const resolvedInfo = buffer.getAttributeInfo(name);
174
+ if (!resolvedBuffer || !resolvedInfo) {
175
+ continue;
176
+ }
177
+ glw.enableVertexAttribArray(i);
178
+ glw.vertexAttribPointer(resolvedBuffer, i, resolvedInfo.size, resolvedInfo.type, resolvedInfo.normalized, resolvedInfo.stride, resolvedInfo.offset);
179
+ }
180
+ }
181
+ bindTextures(textures) {
182
+ this.glw.activeTexture(0);
183
+ this.glw.bindTexture(textures[0].ctxTexture);
184
+ }
185
+ attach() {
186
+ this.glw.useProgram(this.program);
187
+ if (this.glw.isWebGl2() && this.vao) {
188
+ this.glw.bindVertexArray(this.vao);
189
+ }
190
+ }
191
+ detach() {
192
+ this.disableAttributes();
193
+ }
194
+ }
195
+ //# sourceMappingURL=WebGlShaderProgram.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebGlShaderProgram.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlShaderProgram.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAQzD,OAAO,EACL,aAAa,EACb,YAAY,GAKb,MAAM,2BAA2B,CAAC;AAEnC,MAAM,OAAO,kBAAkB;IACnB,qBAAqB,GAA4B,IAAI,CAAC;IACtD,OAAO,CAAe;IAChC;;;;;OAKG;IACO,GAAG,CAAqC;IACxC,QAAQ,CAAgB;IACxB,GAAG,CAAsB;IACzB,kBAAkB,CAAyB;IAC3C,SAAS,CAA+C;IACxD,cAAc,GAAG,KAAK,CAAC;IACvB,mBAAmB,GAAG,KAAK,CAAC;IACtC,uBAAuB,GAAG,KAAK,CAAC;IAEhC,YACE,QAAuB,EACvB,MAAuB,EACvB,aAAkC;QAElC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEtC,sCAAsC;QACtC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,kBAAkB,GAAa,EAAE,CAAC;QAEtC,IAAI,CAAC,uBAAuB;YAC1B,MAAM,CAAC,uBAAuB,IAAI,IAAI,CAAC,uBAAuB,CAAC;QACjE,kBAAkB;YAChB,CAAC,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAAC;gBACnC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAAC;gBACpC,EAAE,CAAC;QAEL,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACzC,kBAAkB,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;YAC3C,IAAI,CAAC,GAAG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AC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACpC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import type { Vec4 } from '../../renderers/webgl/internal/ShaderUtils.js';
3
+ import { type BorderProps } from '../templates/BorderTemplate.js';
4
+ export interface ComputedBorderValues {
5
+ borderColor: string;
6
+ borderAsym: boolean;
7
+ borderRadius: Vec4;
8
+ }
9
+ export declare const Border: CanvasShaderType<BorderProps, ComputedBorderValues>;
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { valuesAreEqual } from '../../lib/utils.js';
18
+ import { formatRgba, parseColorRgba, } from '../../renderers/canvas/internal/ColorUtils.js';
19
+ import { BorderTemplate, } from '../templates/BorderTemplate.js';
20
+ import { strokeLine } from './utils/render.js';
21
+ export const Border = {
22
+ props: BorderTemplate.props,
23
+ update() {
24
+ this.computed.borderColor = formatRgba(parseColorRgba(this.props.color));
25
+ this.computed.borderAsym = !valuesAreEqual(this.props.width);
26
+ },
27
+ render(ctx, quad, renderContext) {
28
+ renderContext();
29
+ ctx.strokeStyle = this.computed.borderColor;
30
+ if (this.computed.borderAsym === false && this.props.width[0] > 0) {
31
+ const bWidth = this.props.width[0];
32
+ const bHalfWidth = bWidth * 0.5;
33
+ ctx.lineWidth = bWidth;
34
+ ctx.beginPath();
35
+ ctx.strokeRect(quad.tx + bHalfWidth, quad.ty + bHalfWidth, quad.width - bWidth, quad.height - bWidth);
36
+ return;
37
+ }
38
+ const { 0: t, 1: r, 2: b, 3: l } = this.props.width;
39
+ if (t > 0) {
40
+ const y = quad.ty + t * 0.5;
41
+ strokeLine(ctx, quad.tx, y, quad.tx + quad.width, y, t);
42
+ }
43
+ if (r > 0) {
44
+ const x = quad.tx + quad.width - r * 0.5;
45
+ strokeLine(ctx, x, quad.ty, x, quad.ty + quad.height, r);
46
+ }
47
+ if (b > 0) {
48
+ const y = quad.ty + quad.height - b * 0.5;
49
+ strokeLine(ctx, quad.tx, y, quad.tx + quad.width, y, b);
50
+ }
51
+ if (l > 0) {
52
+ const x = quad.tx + l * 0.5;
53
+ strokeLine(ctx, x, quad.ty, x, quad.ty + quad.height, l);
54
+ }
55
+ },
56
+ };
57
+ //# sourceMappingURL=Border.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Border.js","sourceRoot":"","sources":["../../../../../src/core/shaders/canvas/Border.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,UAAU,EACV,cAAc,GACf,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EACL,cAAc,GAEf,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ/C,MAAM,CAAC,MAAM,MAAM,GAAwD;IACzE,KAAK,EAAE,cAAc,CAAC,KAAK;IAC3B,MAAM;QACJ,IAAI,CAAC,QAAQ,CAAC,WAA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AE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC;YACzC,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG,CAAC;YAC1C,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;YAC5B,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import type { Vec4 } from '../../renderers/webgl/internal/ShaderUtils.js';
3
+ import { type HolePunchProps } from '../templates/HolePunchTemplate.js';
4
+ export interface ComputedHolePunchValues {
5
+ radius: Vec4;
6
+ }
7
+ export declare const HolePunch: CanvasShaderType<HolePunchProps, ComputedHolePunchValues>;
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { calcFactoredRadiusArray } from '../../lib/utils.js';
18
+ import { HolePunchTemplate, } from '../templates/HolePunchTemplate.js';
19
+ import { roundRect } from './utils/render.js';
20
+ export const HolePunch = {
21
+ props: HolePunchTemplate.props,
22
+ update() {
23
+ this.computed.radius = calcFactoredRadiusArray(this.props.radius, this.props.width, this.props.height);
24
+ },
25
+ render(ctx, quad, renderContext) {
26
+ ctx.save();
27
+ renderContext();
28
+ const { x, y, width, height } = this.props;
29
+ ctx.beginPath();
30
+ roundRect(ctx, quad.tx + x, quad.ty + y, width, height, this.computed.radius);
31
+ ctx.closePath();
32
+ ctx.fillStyle = 'black';
33
+ ctx.globalCompositeOperation = 'destination-out';
34
+ ctx.fill();
35
+ ctx.restore();
36
+ },
37
+ };
38
+ //# sourceMappingURL=HolePunch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HolePunch.js","sourceRoot":"","sources":["../../../../../src/core/shaders/canvas/HolePunch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EACL,iBAAiB,GAElB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAM9C,MAAM,CAAC,MAAM,SAAS,GAGlB;IACF,KAAK,EAAE,iBAAiB,CAAC,KAAK;IAC9B,MAAM;QACJ,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,uBAAuB,CAC5C,IAAI,CAAC,KAAM,CAAC,MAAc,EAC1B,IAAI,CAAC,KAAM,CAAC,KAAK,EACjB,IAAI,CAAC,KAAM,CAAC,MAAM,CACnB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa;QAC7B,GAAG,CAAC,IAAI,EAAE,CAAC;QACX,aAAa,EAAE,CAAC;QAChB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAM,CAAC;QAC5C,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,SAAS,CACP,GAAG,EACH,IAAI,CAAC,EAAE,GAAG,CAAC,EACX,IAAI,CAAC,EAAE,GAAG,CAAC,EACX,KAAK,EACL,MAAM,EACN,IAAI,CAAC,QAAQ,CAAC,MAAO,CACtB,CAAC;QACF,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,GAAG,CAAC,SAAS,GAAG,OAAO,CAAC;QACxB,GAAG,CAAC,wBAAwB,GAAG,iBAAiB,CAAC;QACjD,GAAG,CAAC,IAAI,EAAE,CAAC;QACX,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import { type LinearGradientProps } from '../templates/LinearGradientTemplate.js';
3
+ export interface ComputedLinearGradientValues {
4
+ x0: number;
5
+ y0: number;
6
+ x1: number;
7
+ y1: number;
8
+ colors: string[];
9
+ }
10
+ export declare const LinearGradient: CanvasShaderType<LinearGradientProps, ComputedLinearGradientValues>;
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { LinearGradientTemplate, } from '../templates/LinearGradientTemplate.js';
18
+ export const LinearGradient = {
19
+ props: LinearGradientTemplate.props,
20
+ update(node) {
21
+ const angle = this.props.angle - (Math.PI / 180) * 90;
22
+ const nWidth = node.width;
23
+ const nHeight = node.height;
24
+ const line = (Math.abs(nWidth * Math.sin(angle)) +
25
+ Math.abs(nHeight * Math.cos(angle))) *
26
+ 0.5;
27
+ this.computed = {
28
+ x0: line * Math.cos(angle) + nWidth * 0.5,
29
+ y0: line * Math.sin(angle) + nHeight * 0.5,
30
+ x1: line * Math.cos(angle + Math.PI) + nWidth * 0.5,
31
+ y1: line * Math.sin(angle + Math.PI) + nHeight * 0.5,
32
+ colors: this.props.colors.map((value) => this.toColorString(value)),
33
+ };
34
+ },
35
+ render(ctx, quad, renderContext) {
36
+ renderContext();
37
+ const gradient = ctx.createLinearGradient(quad.tx + this.computed.x0, quad.ty + this.computed.y0, quad.tx + this.computed.x1, quad.ty + this.computed.y1);
38
+ const colors = this.computed.colors;
39
+ for (let i = 0; i < colors.length; i++) {
40
+ gradient.addColorStop(this.props['stops'][i], colors[i]);
41
+ }
42
+ ctx.fillStyle = gradient;
43
+ ctx.fillRect(quad.tx, quad.ty, quad.width, quad.height);
44
+ },
45
+ };
46
+ //# sourceMappingURL=LinearGradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinearGradient.js","sourceRoot":"","sources":["../../../../../src/core/shaders/canvas/LinearGradient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,s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AAE,CAAC;QAChB,MAAM,QAAQ,GAAG,GAAG,CAAC,oBAAoB,CACvC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAG,EAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAG,EAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAG,EAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAG,CAC5B,CAAC;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAO,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,EAAE,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;QAC9D,CAAC;QACD,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC;QACzB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import { type RadialGradientProps } from '../templates/RadialGradientTemplate.js';
3
+ export interface ComputedRadialGradientValues {
4
+ pivotX: number;
5
+ pivotY: number;
6
+ scaleX: number;
7
+ scaleY: number;
8
+ size: number;
9
+ colors: string[];
10
+ }
11
+ export declare const RadialGradient: CanvasShaderType<RadialGradientProps, ComputedRadialGradientValues>;
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { RadialGradientTemplate, } from '../templates/RadialGradientTemplate.js';
18
+ export const RadialGradient = {
19
+ props: RadialGradientTemplate.props,
20
+ update(node) {
21
+ let scaleX = 1;
22
+ let scaleY = 1;
23
+ const pWidth = this.props.width;
24
+ const pHeight = this.props.height;
25
+ if (pWidth > pHeight) {
26
+ scaleX = pWidth / pHeight;
27
+ }
28
+ else if (pHeight > pWidth) {
29
+ scaleY = pHeight / pWidth;
30
+ }
31
+ this.computed = {
32
+ pivotX: this.props.pivot[0] * node.width,
33
+ pivotY: this.props.pivot[1] * node.height,
34
+ scaleX,
35
+ scaleY,
36
+ size: Math.min(pWidth, pHeight) * 0.5,
37
+ colors: this.props.colors.map((value) => this.toColorString(value)),
38
+ };
39
+ },
40
+ render(ctx, quad, renderContext) {
41
+ renderContext();
42
+ const { scaleX, scaleY, pivotX, pivotY } = this.computed;
43
+ const colors = this.computed.colors;
44
+ let x = quad.tx + pivotX;
45
+ let y = quad.ty + pivotY;
46
+ if (scaleX === scaleY) {
47
+ const gradient = ctx.createRadialGradient(x, y, 0, x, y, this.computed.size);
48
+ for (let i = 0; i < colors.length; i++) {
49
+ gradient.addColorStop(this.props['stops'][i], colors[i]);
50
+ }
51
+ ctx.fillStyle = gradient;
52
+ ctx.fillRect(quad.tx, quad.ty, quad.width, quad.height);
53
+ return;
54
+ }
55
+ ctx.save();
56
+ ctx.scale(scaleX, scaleY);
57
+ x = x / scaleX;
58
+ y = y / scaleY;
59
+ const gradient = ctx.createRadialGradient(x, y, 0, x, y, this.computed.size);
60
+ for (let i = 0; i < colors.length; i++) {
61
+ gradient.addColorStop(this.props['stops'][i], colors[i]);
62
+ }
63
+ ctx.fillStyle = gradient;
64
+ ctx.fillRect(quad.tx / scaleX, quad.ty / scaleY, quad.width / scaleX, quad.height / scaleY);
65
+ ctx.restore();
66
+ },
67
+ };
68
+ //# sourceMappingURL=RadialGradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadialGradient.js","sourceRoot":"","sources":["../../../../../src/core/shaders/canvas/RadialGradient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,sBAAsB,GAEvB,MAAM,wCAAwC,CAAC;AAWhD,MAAM,CAAC,MAAM,cAAc,GAGvB;IACF,KAAK,EAAE,sBAAsB,CAAC,KAAK;IACnC,MAAM,CAAC,IAAI;QACT,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,IAAI,MAAM,GAAG,CAAC,CAAC;QAEf,MAAM,MAAM,GAAG,IAAI,CAAC,KAAM,CAAC,KAAK,CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAM,CAAC,MAAM,CAAC;QACnC,IAAI,MAAM,GAAG,OAAO,EAAE,CAAC;YACrB,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAC5B,CAAC;aAAM,IAAI,OAAO,GAAG,MAAM,EAAE,CAAC;YAC5B,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG;YACd,MAAM,EAAE,IAAI,CAAC,KAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;YACzC,MAAM,EAAE,IAAI,CAAC,KAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM;YAC1C,MAAM;YACN,MAAM;YACN,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG;YACrC,MAAM,EAAE,IAAI,CAAC,KA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CAAC,GAAG,MAAO,CAAC;QAChB,CAAC,GAAG,CAAC,GAAG,MAAO,CAAC;QAChB,MAAM,QAAQ,GAAG,GAAG,CAAC,oBAAoB,CACvC,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,IAAI,CAAC,QAAQ,CAAC,IAAK,CACpB,CAAC;QAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,EAAE,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC;QAC9D,CAAC;QAED,GAAG,CAAC,SAAS,GAAG,QAAQ,CAAC;QACzB,GAAG,CAAC,QAAQ,CACV,IAAI,CAAC,EAAE,GAAG,MAAO,EACjB,IAAI,CAAC,EAAE,GAAG,MAAO,EACjB,IAAI,CAAC,KAAK,GAAG,MAAO,EACpB,IAAI,CAAC,MAAM,GAAG,MAAO,CACtB,CAAC;QAEF,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import type { Vec4 } from '../../renderers/webgl/internal/ShaderUtils.js';
3
+ import { type RoundedProps } from '../templates/RoundedTemplate.js';
4
+ export interface ComputedRoundedValues {
5
+ radius: Vec4;
6
+ }
7
+ export declare const Rounded: CanvasShaderType<RoundedProps, ComputedRoundedValues>;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { calcFactoredRadiusArray } from '../../lib/utils.js';
18
+ import { RoundedTemplate, } from '../templates/RoundedTemplate.js';
19
+ import { roundRect } from './utils/render.js';
20
+ export const Rounded = {
21
+ props: RoundedTemplate.props,
22
+ saveAndRestore: true,
23
+ update(node) {
24
+ this.computed.radius = calcFactoredRadiusArray(this.props.radius, node.width, node.height);
25
+ },
26
+ render(ctx, quad, renderContext) {
27
+ const path = new Path2D();
28
+ roundRect(path, quad.tx, quad.ty, quad.width, quad.height, this.computed.radius);
29
+ ctx.clip(path);
30
+ renderContext();
31
+ },
32
+ };
33
+ //# sourceMappingURL=Rounded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rounded.js","sourceRoot":"","sources":["../../../../../src/core/shaders/canvas/Rounded.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EACL,eAAe,GAEhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAM9C,MAAM,CAAC,MAAM,OAAO,GAA0D;IAC5E,KAAK,EAAE,eAAe,CAAC,KAAK;IAC5B,cAAc,EAAE,IAAI;IACpB,MAAM,CAAC,IAAI;QACT,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,uBAAuB,CAC5C,IAAI,CAAC,KAAM,CAAC,MAAc,EAC1B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa;QAC7B,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QAC1B,SAAS,CACP,IAAI,EACJ,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,QAAQ,CAAC,MAAO,CACtB,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEf,aAAa,EAAE,CAAC;IAClB,CAAC;CACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import { type RoundedWithBorderProps } from '../templates/RoundedWithBorderTemplate.js';
3
+ import type { ComputedBorderValues } from './Border.js';
4
+ import type { ComputedRoundedValues } from './Rounded.js';
5
+ type ComputedValues = ComputedRoundedValues & ComputedBorderValues;
6
+ export declare const RoundedWithBorder: CanvasShaderType<RoundedWithBorderProps, ComputedValues>;
7
+ export {};
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { calcFactoredRadiusArray, valuesAreEqual } from '../../lib/utils.js';
18
+ import { RoundedWithBorderTemplate, } from '../templates/RoundedWithBorderTemplate.js';
19
+ import { roundedRectWithBorder } from './utils/render.js';
20
+ export const RoundedWithBorder = {
21
+ props: RoundedWithBorderTemplate.props,
22
+ saveAndRestore: true,
23
+ update(node) {
24
+ const radius = calcFactoredRadiusArray(this.props.radius, node.width, node.height);
25
+ this.computed.radius = radius;
26
+ this.computed.borderColor = this.toColorString(this.props['border-color']);
27
+ this.computed.borderAsym = !valuesAreEqual(this.props['border-width']);
28
+ const borderWidth = this.props['border-width'];
29
+ this.computed.borderRadius = radius.map((value, index) => Math.max(0, value - borderWidth[index] * 0.5));
30
+ },
31
+ render(ctx, quad, renderContext) {
32
+ roundedRectWithBorder(ctx, quad.tx, quad.ty, quad.width, quad.height, this.computed.radius, this.props['border-width'], this.computed.borderRadius, this.computed.borderColor, this.computed.borderAsym, renderContext);
33
+ },
34
+ };
35
+ //# sourceMappingURL=RoundedWithBorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoundedWithBorder.js","sourceRoot":"","sources":["../../../../../src/core/shaders/canvas/RoundedWithBorder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACL,yBAAyB,GAE1B,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI1D,MAAM,CAAC,MAAM,iBAAiB,GAG1B;IACF,KAAK,EAAE,yBAAyB,CAAC,KAAK;IACtC,cAAc,EAAE,IAAI;IACpB,MAAM,CAAC,IAAI;QACT,MAAM,MAAM,GAAG,uBAAuB,CACpC,IAAI,CAAC,KAAM,CAAC,MAAc,EAC1B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,CACZ,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAM,CAAC,cAAc,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,CAAC,cAAc,CACxC,IAAI,CAAC,KAAM,CAAC,cAAc,CAAa,CACxC,CAAC;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAM,CAAC,cAAc,CAAS,CAAC;QACxD,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACvD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,KAAK,CAAE,GAAG,GAAG,CAAC,CACvC,CAAC;IACZ,CAAC;IACD,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa;QAC7B,qBAAqB,CACnB,GAAG,EACH,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,QAAQ,CAAC,MAAO,EACrB,IAAI,CAAC,KAAM,CAAC,cAAc,CAAS,EACnC,IAAI,CAAC,QAAQ,CAAC,YAAa,EAC3B,IAAI,CAAC,QAAQ,CAAC,WAAY,EAC1B,IAAI,CAAC,QAAQ,CAAC,UAAW,EACzB,aAAa,CACd,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { CanvasShaderType } from '../../renderers/canvas/CanvasShaderNode.js';
2
+ import { type RoundedWithBorderAndShadowProps } from '../templates/RoundedWithBorderAndShadowTemplate.js';
3
+ import type { ComputedBorderValues } from './Border.js';
4
+ import type { ComputedRoundedValues } from './Rounded.js';
5
+ import type { ComputedShadowValues } from './Shadow.js';
6
+ type ComputedValues = ComputedRoundedValues & ComputedBorderValues & ComputedShadowValues;
7
+ export declare const RoundedWithBorderAndShadow: CanvasShaderType<RoundedWithBorderAndShadowProps, ComputedValues>;
8
+ export {};
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2023 Comcast Cable Communications Management, LLC
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ *
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ import { calcFactoredRadiusArray, valuesAreEqual } from '../../lib/utils.js';
18
+ import { RoundedWithBorderAndShadowTemplate, } from '../templates/RoundedWithBorderAndShadowTemplate.js';
19
+ import * as render from './utils/render.js';
20
+ export const RoundedWithBorderAndShadow = {
21
+ props: RoundedWithBorderAndShadowTemplate.props,
22
+ saveAndRestore: true,
23
+ update(node) {
24
+ const radius = calcFactoredRadiusArray(this.props.radius, node.width, node.height);
25
+ this.computed.radius = radius;
26
+ this.computed.borderColor = this.toColorString(this.props['border-color']);
27
+ this.computed.borderAsym = !valuesAreEqual(this.props['border-width']);
28
+ const borderWidth = this.props['border-width'];
29
+ this.computed.borderRadius = radius.map((value, index) => Math.max(0, value - borderWidth[index] * 0.5));
30
+ this.computed.shadowColor = this.toColorString(this.props['shadow-color']);
31
+ this.computed.shadowRadius = radius.map((value) => value + this.props['shadow-blur']);
32
+ },
33
+ render(ctx, quad, renderContext) {
34
+ const { tx, ty, width, height } = quad;
35
+ render.shadow(ctx, tx, ty, height, width, this.computed.shadowColor, this.props['shadow-projection'], this.computed.shadowRadius, this.stage.pixelRatio);
36
+ render.roundedRectWithBorder(ctx, quad.tx, quad.ty, quad.width, quad.height, this.computed.radius, this.props['border-width'], this.computed.borderRadius, this.computed.borderColor, this.computed.borderAsym, renderContext);
37
+ },
38
+ };
39
+ //# sourceMappingURL=RoundedWithBorderAndShadow.js.map