webglmusti 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/.gitattributes +2 -0
  2. package/idea_list.txt +13 -0
  3. package/index.html +17 -0
  4. package/package.json +20 -0
  5. package/public/apple.png +0 -0
  6. package/public/base.png +0 -0
  7. package/public/car.png +0 -0
  8. package/public/drop.png +0 -0
  9. package/public/font16-Sheet.png +0 -0
  10. package/public/font16-Sheet.txt +52 -0
  11. package/public/letters-Sheet.png +0 -0
  12. package/public/letters-Sheet.txt +27 -0
  13. package/public/letters_Sheet.png +0 -0
  14. package/public/letters_Sheet.txt +4 -0
  15. package/public/vite.svg +1 -0
  16. package/src/App/ResourceSim/car.ts +172 -0
  17. package/src/App/ResourceSim/grid.ts +993 -0
  18. package/src/App/ResourceSim/grid_app.ts +1326 -0
  19. package/src/App/ResourceSim/grid_test.test.ts +18 -0
  20. package/src/App/ResourceSim/node_graph.ts +293 -0
  21. package/src/App/ResourceSim/nodes.ts +151 -0
  22. package/src/App/ResourceSim/resource.ts +8 -0
  23. package/src/App/ResourceSim/texts.ts +6 -0
  24. package/src/App/card/card.test.ts +22 -0
  25. package/src/App/card/card.ts +763 -0
  26. package/src/App/puzzle_box/app.ts +10 -0
  27. package/src/App/puzzle_box/engine.ts +374 -0
  28. package/src/App/puzzle_box/renderer.ts +102 -0
  29. package/src/App/puzzle_box/test.test.ts +49 -0
  30. package/src/App/water/water.ts +206 -0
  31. package/src/Interface/button.ts +345 -0
  32. package/src/Interface/interface_element.ts +30 -0
  33. package/src/Interface/internal_window.ts +100 -0
  34. package/src/Interface/options.ts +332 -0
  35. package/src/Interface/text_input.ts +183 -0
  36. package/src/WebGL/Matrix/matrix.test.ts +30 -0
  37. package/src/WebGL/Matrix/matrix.ts +293 -0
  38. package/src/WebGL/Shaders/Fragment/Program/circle.ts +49 -0
  39. package/src/WebGL/Shaders/Fragment/Program/circle_only.ts +47 -0
  40. package/src/WebGL/Shaders/Fragment/Program/circle_outline.ts +54 -0
  41. package/src/WebGL/Shaders/Fragment/Program/colour.ts +39 -0
  42. package/src/WebGL/Shaders/Fragment/Program/colour_alpha.ts +37 -0
  43. package/src/WebGL/Shaders/Fragment/Program/line.ts +39 -0
  44. package/src/WebGL/Shaders/Fragment/Program/multi_colour_centre_circle_path.ts +69 -0
  45. package/src/WebGL/Shaders/Fragment/Program/multi_colour_path.ts +69 -0
  46. package/src/WebGL/Shaders/Fragment/Program/path_centre_circle.ts +69 -0
  47. package/src/WebGL/Shaders/Fragment/Program/rect_outline.ts +39 -0
  48. package/src/WebGL/Shaders/Fragment/Program/solid_path.ts +64 -0
  49. package/src/WebGL/Shaders/Fragment/Program/sprite_sheet.ts +54 -0
  50. package/src/WebGL/Shaders/Fragment/Program/sprite_sheet_colour.ts +62 -0
  51. package/src/WebGL/Shaders/Fragment/Program/texture.ts +34 -0
  52. package/src/WebGL/Shaders/Fragment/Source/circle.frag +19 -0
  53. package/src/WebGL/Shaders/Fragment/Source/circle_only.frag +15 -0
  54. package/src/WebGL/Shaders/Fragment/Source/circle_outline.frag +23 -0
  55. package/src/WebGL/Shaders/Fragment/Source/colour.frag +9 -0
  56. package/src/WebGL/Shaders/Fragment/Source/colour_alpha.frag +7 -0
  57. package/src/WebGL/Shaders/Fragment/Source/fragment.frag +5 -0
  58. package/src/WebGL/Shaders/Fragment/Source/fragment_source.ts +15 -0
  59. package/src/WebGL/Shaders/Fragment/Source/line.frag +12 -0
  60. package/src/WebGL/Shaders/Fragment/Source/multi_colour_centre_circle_path.frag +36 -0
  61. package/src/WebGL/Shaders/Fragment/Source/multi_colour_path.frag +34 -0
  62. package/src/WebGL/Shaders/Fragment/Source/path_centre_circle.frag +29 -0
  63. package/src/WebGL/Shaders/Fragment/Source/rect_outline.frag +20 -0
  64. package/src/WebGL/Shaders/Fragment/Source/solid_path.frag +24 -0
  65. package/src/WebGL/Shaders/Fragment/Source/sprite_sheet.frag +17 -0
  66. package/src/WebGL/Shaders/Fragment/Source/sprite_sheet_colour.frag +19 -0
  67. package/src/WebGL/Shaders/Fragment/Source/texture.frag +11 -0
  68. package/src/WebGL/Shaders/Fragment/fragment.ts +43 -0
  69. package/src/WebGL/Shaders/Fragment/fragment_old.ts +261 -0
  70. package/src/WebGL/Shaders/Vertex/Program/mvp2d.ts +41 -0
  71. package/src/WebGL/Shaders/Vertex/Program/transform2d.ts +39 -0
  72. package/src/WebGL/Shaders/Vertex/Source/mvp2d.vert +17 -0
  73. package/src/WebGL/Shaders/Vertex/Source/mvp_i_2d.vert +18 -0
  74. package/src/WebGL/Shaders/Vertex/Source/simple.vert +9 -0
  75. package/src/WebGL/Shaders/Vertex/Source/transform2d.vert +13 -0
  76. package/src/WebGL/Shaders/Vertex/Source/transform2d_rel.vert +16 -0
  77. package/src/WebGL/Shaders/Vertex/Source/translate2d.vert +7 -0
  78. package/src/WebGL/Shaders/Vertex/Source/vertex_source.ts +13 -0
  79. package/src/WebGL/Shaders/Vertex/vertex.ts +10 -0
  80. package/src/WebGL/Shaders/Vertex/vertex_old.ts +289 -0
  81. package/src/WebGL/Shaders/custom.ts +129 -0
  82. package/src/WebGL/Shaders/shader.ts +197 -0
  83. package/src/WebGL/Shapes/Line.ts +29 -0
  84. package/src/WebGL/Shapes/Shapes.ts +189 -0
  85. package/src/WebGL/Texture/texture.ts +214 -0
  86. package/src/WebGL/Util/file.ts +24 -0
  87. package/src/WebGL/app.ts +150 -0
  88. package/src/WebGL/colour.ts +71 -0
  89. package/src/WebGL/globals.ts +353 -0
  90. package/src/WebGL/index.ts +3 -0
  91. package/src/WebGL/mixin.ts +2 -0
  92. package/src/global.d.ts +13 -0
  93. package/src/index.ts +4 -0
  94. package/src/main.ts +139 -0
  95. package/src/utils/array.ts +154 -0
  96. package/src/utils/assert.ts +8 -0
  97. package/src/utils/file.ts +0 -0
  98. package/src/utils/mixin.ts +22 -0
  99. package/src/utils/numbers.ts +11 -0
  100. package/src/utils/utils.test.ts +23 -0
  101. package/src/vite-env.d.ts +1 -0
  102. package/tsconfig.json +25 -0
@@ -0,0 +1,293 @@
1
+ type Float = number;
2
+
3
+ export class Point2D{
4
+ x: Float;
5
+ y: Float;
6
+ constructor(x: Float=0, y: Float=0){
7
+ this.x = x;
8
+ this.y = y;
9
+ }
10
+ equals(p: Point2D): boolean{
11
+ return this.x === p.x && this.y === p.y;
12
+ }
13
+ }
14
+
15
+ export class Matrix2x2{
16
+ protected _matrix: Float32Array;
17
+ constructor(){
18
+ this._matrix = new Float32Array(4);
19
+ }
20
+ get matrix(): Float32Array{
21
+ return this._matrix;
22
+ }
23
+ }
24
+
25
+ export class Matrix3x3{
26
+ protected _matrix: Float32Array;
27
+ constructor(){
28
+ this._matrix = new Float32Array(9);
29
+ }
30
+ get matrix(): Float32Array{
31
+ return this._matrix;
32
+ }
33
+ static new(arr: Float[]): Matrix3x3{
34
+ const mat = new Matrix3x3();
35
+ mat.setMatrix(arr);
36
+ return mat;
37
+ }
38
+ setMatrix(mat: Float[]){
39
+ const lim = Math.min(9, mat.length);
40
+ for(let i = 0; i < lim; i++){
41
+ this._matrix[i] = mat[i];
42
+ }
43
+ }
44
+ static identity(): Matrix3x3{
45
+ const mat = new Matrix3x3();
46
+ mat._matrix[0] = 1.0;
47
+ mat._matrix[4] = 1.0;
48
+ mat._matrix[8] = 1.0;
49
+ return mat;
50
+ }
51
+ multiplyScalar(scalar: Float){
52
+ for(let i = 0; i < 9; i++){
53
+ this._matrix[i] *= scalar;
54
+ }
55
+ }
56
+ matrixMinorsCopy(): Matrix3x3{
57
+ const minors = new Matrix3x3();
58
+ minors._matrix[0] = this._matrix[4]*this._matrix[8] - this._matrix[5]*this._matrix[7];
59
+ minors._matrix[1] = this._matrix[3]*this._matrix[8] - this._matrix[5]*this._matrix[6];
60
+ minors._matrix[2] = this._matrix[3]*this._matrix[7] - this._matrix[4]*this._matrix[6];
61
+ minors._matrix[3] = this._matrix[1]*this._matrix[8] - this._matrix[2]*this._matrix[7];
62
+ minors._matrix[4] = this._matrix[0]*this._matrix[8] - this._matrix[2]*this._matrix[6];
63
+ minors._matrix[5] = this._matrix[0]*this._matrix[7] - this._matrix[1]*this._matrix[6];
64
+ minors._matrix[6] = this._matrix[1]*this._matrix[5] - this._matrix[2]*this._matrix[4];
65
+ minors._matrix[7] = this._matrix[0]*this._matrix[5] - this._matrix[2]*this._matrix[3];
66
+ minors._matrix[8] = this._matrix[0]*this._matrix[4] - this._matrix[1]*this._matrix[3];
67
+ return minors;
68
+ }
69
+ matrixCofactorsCopy(): Matrix3x3{
70
+ const cof = this.matrixMinorsCopy();
71
+ cof._matrix[1] *= -1;
72
+ cof._matrix[3] *= -1;
73
+ cof._matrix[5] *= -1;
74
+ cof._matrix[7] *= -1;
75
+ return cof;
76
+ }
77
+ adjugateCopy(): Matrix3x3{
78
+ const adj = new Matrix3x3();
79
+ adj._matrix[0] = this._matrix[0];
80
+ adj._matrix[1] = this._matrix[3];
81
+ adj._matrix[2] = this._matrix[6];
82
+ adj._matrix[3] = this._matrix[1];
83
+ adj._matrix[4] = this._matrix[4];
84
+ adj._matrix[5] = this._matrix[7];
85
+ adj._matrix[6] = this._matrix[2];
86
+ adj._matrix[7] = this._matrix[5];
87
+ adj._matrix[8] = this._matrix[8];
88
+ return adj;
89
+ }
90
+ determinant(): Float{
91
+ const a_minor = this._matrix[4]*this._matrix[8] - this._matrix[5]*this._matrix[7];
92
+ const b_minor = this._matrix[3]*this._matrix[8] - this._matrix[5]*this._matrix[6];
93
+ const c_minor = this._matrix[3]*this._matrix[7] - this._matrix[4]*this._matrix[6];
94
+ return this._matrix[0]*a_minor - this._matrix[1]*b_minor + this._matrix[2]*c_minor;
95
+ }
96
+
97
+ invert(){
98
+ const determinant = this.determinant();
99
+ const cofactors = this.matrixCofactorsCopy();
100
+ const inverse = cofactors.adjugateCopy();
101
+ inverse.multiplyScalar(1/determinant);
102
+
103
+ for(let i = 0; i < 9; i++){
104
+ this._matrix[i] = inverse._matrix[i];
105
+ }
106
+ }
107
+
108
+ inverseCopy(): Matrix3x3{
109
+ const determinant = this.determinant();
110
+ const cofactors = this.matrixCofactorsCopy();
111
+ const inverse = cofactors.adjugateCopy();
112
+ inverse.multiplyScalar(1/determinant);
113
+ return inverse;
114
+ }
115
+
116
+ copy(): Matrix3x3{
117
+ const c = new Matrix3x3();
118
+ for(let i = 0; i < 9; i++){
119
+ c._matrix[i] = this._matrix[i];
120
+ }
121
+ return c;
122
+ }
123
+
124
+ static equals(m1: Matrix3x3, m2: Matrix3x3){
125
+ for(let i = 0; i < 9; i++){
126
+ if(m1._matrix[i] !== m2._matrix[i]){
127
+ return false;
128
+ }
129
+ }
130
+ return true;
131
+ }
132
+
133
+ print(){
134
+ console.log(`|${this._matrix[0].toFixed(2)} ${this._matrix[1].toFixed(2)} ${this._matrix[2].toFixed(2)}|`);
135
+ console.log(`|${this._matrix[3].toFixed(2)} ${this._matrix[4].toFixed(2)} ${this._matrix[5].toFixed(2)}|`);
136
+ console.log(`|${this._matrix[6].toFixed(2)} ${this._matrix[7].toFixed(2)} ${this._matrix[8].toFixed(2)}|`);
137
+ }
138
+ }
139
+
140
+ export class TransformationMatrix3x3 extends Matrix3x3{
141
+ //private _matrix: Float32Array;
142
+ constructor(){
143
+ super();
144
+ //this._matrix = new Float32Array(9);
145
+ }
146
+ static new(arr: Float[]): TransformationMatrix3x3{
147
+ const mat = new TransformationMatrix3x3();
148
+ mat.setMatrix(arr);
149
+ return mat;
150
+ }
151
+ static newMatrix(cmat: Matrix3x3): TransformationMatrix3x3{
152
+ const mat = new TransformationMatrix3x3();
153
+ for(let i = 0; i < 9; i++){
154
+ mat._matrix[i] = cmat.matrix[i];
155
+ }
156
+ return mat;
157
+ }
158
+
159
+ static identity(): TransformationMatrix3x3{
160
+ const mat = new TransformationMatrix3x3();
161
+ mat._matrix[0] = 1.0;
162
+ mat._matrix[4] = 1.0;
163
+ mat._matrix[8] = 1.0;
164
+ return mat;
165
+ }
166
+
167
+ static orthographic(left: number, right: number, bottom: number, top: number): TransformationMatrix3x3{
168
+ const mat = TransformationMatrix3x3.identity();
169
+ mat._matrix[0] = 2/(right-left);
170
+ mat._matrix[4] = 2/(top-bottom);
171
+ mat._matrix[6] = (right+left)/(left-right);
172
+ mat._matrix[7] = (top+bottom)/(bottom-top);
173
+ return mat;
174
+ }
175
+
176
+ static projection(){
177
+
178
+ }
179
+
180
+ static translate(tx: number, ty: number): TransformationMatrix3x3{
181
+ const mat = TransformationMatrix3x3.identity();
182
+ mat._matrix[6] = tx;
183
+ mat._matrix[7] = ty;
184
+ return mat;
185
+ }
186
+
187
+ static scale(sx: number, sy: number): TransformationMatrix3x3{
188
+ const mat = TransformationMatrix3x3.identity();
189
+ mat._matrix[0] = sx;
190
+ mat._matrix[4] = sy;
191
+ return mat;
192
+ }
193
+
194
+ static rotate(radians: number): TransformationMatrix3x3{
195
+ const mat = TransformationMatrix3x3.identity();
196
+ const c = Math.cos(radians);
197
+ const s = Math.sin(radians);
198
+ mat._matrix[0] = c;
199
+ mat._matrix[1] = s;
200
+ mat._matrix[3] = -s;
201
+ mat._matrix[4] = c;
202
+ return mat;
203
+ }
204
+
205
+ static rotateY(radians: number): TransformationMatrix3x3{
206
+ const mat = TransformationMatrix3x3.identity();
207
+ const c = Math.cos(radians);
208
+ const s = Math.sin(radians);
209
+ mat._matrix[0] = c;
210
+ mat._matrix[6] = s;
211
+ //mat._matrix[2] = -s;
212
+ //mat._matrix[8] = c;
213
+ return mat;
214
+ }
215
+
216
+ static rotateX(radians: number): TransformationMatrix3x3{
217
+ const mat = TransformationMatrix3x3.identity();
218
+ const c = Math.cos(radians);
219
+ const s = Math.sin(radians);
220
+ mat._matrix[4] = c;
221
+ //mat._matrix[5] = -s;
222
+ mat._matrix[7] = s;
223
+ //mat._matrix[8] = c;
224
+ return mat;
225
+ }
226
+
227
+ setIdentity(){
228
+ this._matrix = new Float32Array(9);
229
+ this._matrix[0] = 1.0;
230
+ this._matrix[4] = 1.0;
231
+ this._matrix[8] = 1.0;
232
+ }
233
+ //static translate()
234
+
235
+ translate(tx: number, ty: number){
236
+ const tr_matrix = TransformationMatrix3x3.translate(tx, ty);
237
+ this.multiply(tr_matrix);
238
+ }
239
+ scale(sx: number, sy: number){
240
+ const sc_matrix = TransformationMatrix3x3.scale(sx, sy);
241
+ this.multiply(sc_matrix);
242
+ }
243
+
244
+ rotate(radians: number){
245
+ const rotation_matrix = TransformationMatrix3x3.rotate(radians);
246
+ this.multiply(rotation_matrix);
247
+ }
248
+
249
+ multiply(mat: TransformationMatrix3x3){
250
+ const temp = this.copy();
251
+ this._matrix[0] = temp._matrix[0]*mat._matrix[0] + temp._matrix[3]*mat._matrix[1] + temp.matrix[6]*mat._matrix[2];
252
+ this._matrix[1] = temp._matrix[1]*mat._matrix[0] + temp._matrix[4]*mat._matrix[1] + temp.matrix[7]*mat._matrix[2];
253
+ this._matrix[2] = temp._matrix[2]*mat._matrix[0] + temp._matrix[5]*mat._matrix[1] + temp.matrix[8]*mat._matrix[2];
254
+
255
+ this._matrix[3] = temp._matrix[0]*mat._matrix[3] + temp._matrix[3]*mat._matrix[4] + temp.matrix[6]*mat._matrix[5];
256
+ this._matrix[4] = temp._matrix[1]*mat._matrix[3] + temp._matrix[4]*mat._matrix[4] + temp.matrix[7]*mat._matrix[5];
257
+ this._matrix[5] = temp._matrix[2]*mat._matrix[3] + temp._matrix[5]*mat._matrix[4] + temp.matrix[8]*mat._matrix[5];
258
+
259
+ this._matrix[6] = temp._matrix[0]*mat._matrix[6] + temp._matrix[3]*mat._matrix[7] + temp.matrix[6]*mat._matrix[8];
260
+ this._matrix[7] = temp._matrix[1]*mat._matrix[6] + temp._matrix[4]*mat._matrix[7] + temp.matrix[7]*mat._matrix[8];
261
+ this._matrix[8] = temp._matrix[2]*mat._matrix[6] + temp._matrix[5]*mat._matrix[7] + temp.matrix[8]*mat._matrix[8];
262
+ }
263
+
264
+ multiplyCopy(mat: TransformationMatrix3x3): TransformationMatrix3x3{
265
+ const cpy = this.copy();
266
+ cpy._matrix[0] = this._matrix[0]*mat._matrix[0] + this._matrix[3]*mat._matrix[1] + this.matrix[6]*mat._matrix[2];
267
+ cpy._matrix[1] = this._matrix[1]*mat._matrix[0] + this._matrix[4]*mat._matrix[1] + this.matrix[7]*mat._matrix[2];
268
+ cpy._matrix[2] = this._matrix[2]*mat._matrix[0] + this._matrix[5]*mat._matrix[1] + this.matrix[8]*mat._matrix[2];
269
+
270
+ cpy._matrix[3] = this._matrix[0]*mat._matrix[3] + this._matrix[3]*mat._matrix[4] + this.matrix[6]*mat._matrix[5];
271
+ cpy._matrix[4] = this._matrix[1]*mat._matrix[3] + this._matrix[4]*mat._matrix[4] + this.matrix[7]*mat._matrix[5];
272
+ cpy._matrix[5] = this._matrix[2]*mat._matrix[3] + this._matrix[5]*mat._matrix[4] + this.matrix[8]*mat._matrix[5];
273
+
274
+ cpy._matrix[6] = this._matrix[0]*mat._matrix[6] + this._matrix[3]*mat._matrix[7] + this.matrix[6]*mat._matrix[8];
275
+ cpy._matrix[7] = this._matrix[1]*mat._matrix[6] + this._matrix[4]*mat._matrix[7] + this.matrix[7]*mat._matrix[8];
276
+ cpy._matrix[8] = this._matrix[2]*mat._matrix[6] + this._matrix[5]*mat._matrix[7] + this.matrix[8]*mat._matrix[8];
277
+ return cpy;
278
+ }
279
+
280
+ transformPoint(point: Point2D): Point2D{
281
+ const x = this._matrix[0] * point.x + this._matrix[3] * point.y + this._matrix[6]
282
+ const y = this._matrix[1] * point.x + this._matrix[4] * point.y + this._matrix[7];
283
+ return new Point2D(x, y);
284
+ }
285
+
286
+ copy(): TransformationMatrix3x3{
287
+ const c = new TransformationMatrix3x3();
288
+ for(let i = 0; i < 9; i++){
289
+ c._matrix[i] = this._matrix[i];
290
+ }
291
+ return c;
292
+ }
293
+ }
@@ -0,0 +1,49 @@
1
+ import Circle from './../Source/circle.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class CircleFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(Circle)){
10
+ console.log('Circle: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function CircleShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class Circle extends Base{
18
+ private declare centre_uniform_location: WebGLUniformLocation | null;
19
+ private declare radius_uniform_location: WebGLUniformLocation | null;
20
+ private declare circle_colour_uniform_location: WebGLUniformLocation | null;
21
+ private declare background_colour_uniform_location: WebGLUniformLocation | null;
22
+ protected override setupFragment(){
23
+ this.fragment_name = 'CircleShader';
24
+ if(CircleFragmentShader.shader){
25
+ this.program.addFragment(CircleFragmentShader.shader)
26
+ }else{
27
+ throw new Error(`${this.fragment_name} not loaded`);
28
+ }
29
+ }
30
+ protected override addFragmentUniformLocations(): void{
31
+ this.centre_uniform_location = this.program.getUniformLocation('u_centre');
32
+ this.radius_uniform_location = this.program.getUniformLocation('u_radius');
33
+ this.circle_colour_uniform_location = this.program.getUniformLocation('u_circle_colour');
34
+ this.background_colour_uniform_location = this.program.getUniformLocation('u_background_colour');
35
+ }
36
+ setCentre(a: GLfloat, b: GLfloat){
37
+ this.program.setFloat2(this.centre_uniform_location!, a, b);
38
+ }
39
+ setRadius(a: GLfloat){
40
+ this.program.setFloat(this.radius_uniform_location!, a);
41
+ }
42
+ setCircle_colour(a: GLfloat, b: GLfloat, c: GLfloat){
43
+ this.program.setFloat3(this.circle_colour_uniform_location!, a, b, c);
44
+ }
45
+ setBackground_colour(a: GLfloat, b: GLfloat, c: GLfloat){
46
+ this.program.setFloat3(this.background_colour_uniform_location!, a, b, c);
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,47 @@
1
+ import CircleOnly from './../Source/circle_only.frag?raw';
2
+ import * as Shader from './../../shader';
3
+ import * as WebGL from './../../../globals';
4
+
5
+ export class CircleOnlyFragmentShader{
6
+ static shader?: Shader.FragmentShader;
7
+ static load(){
8
+ if(this.shader == undefined){
9
+ this.shader = new Shader.FragmentShader();
10
+ if(!this.shader.addSource(CircleOnly)){
11
+ console.log('CircleOnly: fragment source not added');
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ export function CircleOnlyShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
18
+ return class CircleOnly extends Base{
19
+ private declare centre_uniform_location: WebGLUniformLocation | null;
20
+ private declare radius_uniform_location: WebGLUniformLocation | null;
21
+ private declare circle_colour_uniform_location: WebGLUniformLocation | null;
22
+ protected override setupFragment(){
23
+ this.fragment_name = 'CircleOnlyShader';
24
+ if(!CircleOnlyFragmentShader.shader){
25
+ CircleOnlyFragmentShader.load();
26
+ }
27
+ this.program.addFragment(CircleOnlyFragmentShader.shader!);
28
+ }
29
+ protected override addFragmentUniformLocations(): void{
30
+ this.centre_uniform_location = this.program.getUniformLocation('u_centre');
31
+ this.radius_uniform_location = this.program.getUniformLocation('u_radius');
32
+ this.circle_colour_uniform_location = this.program.getUniformLocation('u_circle_colour');
33
+ }
34
+ setCentre(a: GLfloat, b: GLfloat){
35
+ this.program.setFloat2(this.centre_uniform_location!, a, b);
36
+ }
37
+ setRadius(a: GLfloat){
38
+ this.program.setFloat(this.radius_uniform_location!, a);
39
+ }
40
+ setCircleColour(a: GLfloat, b: GLfloat, c: GLfloat){
41
+ this.program.setFloat3(this.circle_colour_uniform_location!, a, b, c);
42
+ }
43
+ setCircleColourFromColourRGB(colour: WebGL.Colour.ColourRGB){
44
+ this.program.setFloat3(this.circle_colour_uniform_location!, colour.red, colour.green, colour.blue);
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,54 @@
1
+ import CircleOutline from './../Source/circle_outline.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class CircleOutlineFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(CircleOutline)){
10
+ console.log('CircleOutline: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function CircleOutlineShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class CircleOutline extends Base{
18
+ private declare centre_uniform_location: WebGLUniformLocation | null;
19
+ private declare radius_uniform_location: WebGLUniformLocation | null;
20
+ private declare outline_radius_uniform_location: WebGLUniformLocation | null;
21
+ private declare outline_colour_uniform_location: WebGLUniformLocation | null;
22
+ private declare background_colour_uniform_location: WebGLUniformLocation | null;
23
+ protected override setupFragment(){
24
+ this.fragment_name = 'CircleOutlineShader';
25
+ if(CircleOutlineFragmentShader.shader){
26
+ this.program.addFragment(CircleOutlineFragmentShader.shader)
27
+ }else{
28
+ throw new Error(`${this.fragment_name} not loaded`);
29
+ }
30
+ }
31
+ protected override addFragmentUniformLocations(): void{
32
+ this.centre_uniform_location = this.program.getUniformLocation('u_centre');
33
+ this.radius_uniform_location = this.program.getUniformLocation('u_radius');
34
+ this.outline_radius_uniform_location = this.program.getUniformLocation('u_outline_radius');
35
+ this.outline_colour_uniform_location = this.program.getUniformLocation('u_outline_colour');
36
+ this.background_colour_uniform_location = this.program.getUniformLocation('u_background_colour');
37
+ }
38
+ setCentre(a: GLfloat, b: GLfloat){
39
+ this.program.setFloat2(this.centre_uniform_location!, a, b);
40
+ }
41
+ setRadius(a: GLfloat){
42
+ this.program.setFloat(this.radius_uniform_location!, a);
43
+ }
44
+ setOutlineRadius(a: GLfloat){
45
+ this.program.setFloat(this.outline_radius_uniform_location!, a);
46
+ }
47
+ setOutlineColour(a: GLfloat, b: GLfloat, c: GLfloat, d: GLfloat){
48
+ this.program.setFloat4(this.outline_colour_uniform_location!, a, b, c, d);
49
+ }
50
+ setBackgroundColour(a: GLfloat, b: GLfloat, c: GLfloat, d: GLfloat){
51
+ this.program.setFloat4(this.background_colour_uniform_location!, a, b, c, d);
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,39 @@
1
+ import Colour from './../Source/colour.frag?raw';
2
+ import * as Shader from './../../shader';
3
+ import * as WebGL from './../../../globals';
4
+
5
+ export class ColourFragmentShader{
6
+ static shader?: Shader.FragmentShader;
7
+ static load(){
8
+ if(this.shader == undefined){
9
+ this.shader = new Shader.FragmentShader();
10
+ if(!this.shader.addSource(Colour)){
11
+ console.log('Colour: fragment source not added');
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ export function ColourShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
18
+ return class Colour extends Base{
19
+ private declare colour_uniform_location: WebGLUniformLocation | null;
20
+ protected override setupFragment(){
21
+ this.fragment_name = 'ColourShader';
22
+ if(!ColourFragmentShader.shader){
23
+ ColourFragmentShader.load();
24
+ }
25
+ this.program.addFragment(ColourFragmentShader.shader!);
26
+ }
27
+ protected override addFragmentUniformLocations(): void{
28
+ this.colour_uniform_location = this.program.getUniformLocation('colour');
29
+ }
30
+ setColour(a: GLfloat, b: GLfloat, c: GLfloat){
31
+ this.program.setFloat3(this.colour_uniform_location!, a, b, c);
32
+ }
33
+
34
+ setColourFromColourRGB(colour: WebGL.Colour.ColourRGB){
35
+ this.program.setFloat3(this.colour_uniform_location!, colour.red, colour.green, colour.blue);
36
+ }
37
+
38
+ }
39
+ }
@@ -0,0 +1,37 @@
1
+ import ColourAlpha from './../Source/colour_alpha.frag?raw';
2
+ import * as Shader from './../../shader';
3
+ import * as WebGL from './../../../globals';
4
+
5
+ export class ColourAlphaFragmentShader{
6
+ static shader?: Shader.FragmentShader;
7
+ static load(){
8
+ if(this.shader == undefined){
9
+ this.shader = new Shader.FragmentShader();
10
+ if(!this.shader.addSource(ColourAlpha)){
11
+ console.log('ColourAlpha: fragment source not added');
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ export function ColourAlphaShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
18
+ return class ColourAlpha extends Base{
19
+ private declare colour_uniform_location: WebGLUniformLocation | null;
20
+ protected override setupFragment(){
21
+ this.fragment_name = 'ColourAlphaShader';
22
+ if(!ColourAlphaFragmentShader.shader){
23
+ ColourAlphaFragmentShader.load();
24
+ }
25
+ this.program.addFragment(ColourAlphaFragmentShader.shader!);
26
+ }
27
+ protected override addFragmentUniformLocations(): void{
28
+ this.colour_uniform_location = this.program.getUniformLocation('colour');
29
+ }
30
+ setColour(a: GLfloat, b: GLfloat, c: GLfloat, d: GLfloat){
31
+ this.program.setFloat4(this.colour_uniform_location!, a, b, c, d);
32
+ }
33
+ setColourFromColourRGBA(colour: WebGL.Colour.ColourRGBA){
34
+ this.program.setFloat4(this.colour_uniform_location!, colour.red, colour.green, colour.blue, colour.alpha);
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,39 @@
1
+ import Line from './../Source/line.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class LineFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(Line)){
10
+ console.log('Line: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function LineShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class Line extends Base{
18
+ private declare thickness_uniform_location: WebGLUniformLocation | null;
19
+ private declare equation_uniform_location: WebGLUniformLocation | null;
20
+ protected override setupFragment(){
21
+ this.fragment_name = 'LineShader';
22
+ if(LineFragmentShader.shader){
23
+ this.program.addFragment(LineFragmentShader.shader)
24
+ }else{
25
+ throw new Error(`${this.fragment_name} not loaded`);
26
+ }
27
+ }
28
+ protected override addFragmentUniformLocations(): void{
29
+ this.thickness_uniform_location = this.program.getUniformLocation('u_thickness');
30
+ this.equation_uniform_location = this.program.getUniformLocation('u_equation');
31
+ }
32
+ setThickness(a: GLfloat){
33
+ this.program.setFloat(this.thickness_uniform_location!, a);
34
+ }
35
+ setEquation(a: GLfloat, b: GLfloat, c: GLfloat){
36
+ this.program.setFloat3(this.equation_uniform_location!, a, b, c);
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,69 @@
1
+ import MultiColourCentreCirclePath from './../Source/multi_colour_centre_circle_path.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class MultiColourCentreCirclePathFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(MultiColourCentreCirclePath)){
10
+ console.log('MultiColourCentreCirclePath: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function MultiColourCentreCirclePathShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class MultiColourCentreCirclePath extends Base{
18
+ private declare left_colour_uniform_location: WebGLUniformLocation | null;
19
+ private declare right_colour_uniform_location: WebGLUniformLocation | null;
20
+ private declare top_colour_uniform_location: WebGLUniformLocation | null;
21
+ private declare bot_colour_uniform_location: WebGLUniformLocation | null;
22
+ private declare mid_colour_uniform_location: WebGLUniformLocation | null;
23
+ private declare circle_radius_uniform_location: WebGLUniformLocation | null;
24
+ private declare size_uniform_location: WebGLUniformLocation | null;
25
+ private declare background_colour_uniform_location: WebGLUniformLocation | null;
26
+ protected override setupFragment(){
27
+ this.fragment_name = 'MultiColourCentreCirclePathShader';
28
+ if(MultiColourCentreCirclePathFragmentShader.shader){
29
+ this.program.addFragment(MultiColourCentreCirclePathFragmentShader.shader)
30
+ }else{
31
+ throw new Error(`${this.fragment_name} not loaded`);
32
+ }
33
+ }
34
+ protected override addFragmentUniformLocations(): void{
35
+ this.left_colour_uniform_location = this.program.getUniformLocation('u_left_colour');
36
+ this.right_colour_uniform_location = this.program.getUniformLocation('u_right_colour');
37
+ this.top_colour_uniform_location = this.program.getUniformLocation('u_top_colour');
38
+ this.bot_colour_uniform_location = this.program.getUniformLocation('u_bot_colour');
39
+ this.mid_colour_uniform_location = this.program.getUniformLocation('u_mid_colour');
40
+ this.circle_radius_uniform_location = this.program.getUniformLocation('u_circle_radius');
41
+ this.size_uniform_location = this.program.getUniformLocation('u_size');
42
+ this.background_colour_uniform_location = this.program.getUniformLocation('u_background_colour');
43
+ }
44
+ setLeftColour(a: GLfloat, b: GLfloat, c: GLfloat){
45
+ this.program.setFloat3(this.left_colour_uniform_location!, a, b, c);
46
+ }
47
+ setRightColour(a: GLfloat, b: GLfloat, c: GLfloat){
48
+ this.program.setFloat3(this.right_colour_uniform_location!, a, b, c);
49
+ }
50
+ setTopColour(a: GLfloat, b: GLfloat, c: GLfloat){
51
+ this.program.setFloat3(this.top_colour_uniform_location!, a, b, c);
52
+ }
53
+ setBotColour(a: GLfloat, b: GLfloat, c: GLfloat){
54
+ this.program.setFloat3(this.bot_colour_uniform_location!, a, b, c);
55
+ }
56
+ setMidColour(a: GLfloat, b: GLfloat, c: GLfloat){
57
+ this.program.setFloat3(this.mid_colour_uniform_location!, a, b, c);
58
+ }
59
+ setCircleRadius(a: GLfloat){
60
+ this.program.setFloat(this.circle_radius_uniform_location!, a);
61
+ }
62
+ setSize(a: GLfloat){
63
+ this.program.setFloat(this.size_uniform_location!, a);
64
+ }
65
+ setBackgroundColour(a: GLfloat, b: GLfloat, c: GLfloat){
66
+ this.program.setFloat3(this.background_colour_uniform_location!, a, b, c);
67
+ }
68
+ }
69
+ }