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,69 @@
1
+ import MultiColourPath from './../Source/multi_colour_path.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class MultiColourPathFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(MultiColourPath)){
10
+ console.log('MultiColourPath: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function MultiColourPathShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class MultiColourPath 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 = 'MultiColourPathShader';
28
+ if(MultiColourPathFragmentShader.shader){
29
+ this.program.addFragment(MultiColourPathFragmentShader.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
+ }
@@ -0,0 +1,69 @@
1
+ import PathCentreCircle from './../Source/path_centre_circle.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class PathCentreCircleFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(PathCentreCircle)){
10
+ console.log('PathCentreCircle: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function PathCentreCircleShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class PathCentreCircle extends Base{
18
+ private declare left_uniform_location: WebGLUniformLocation | null;
19
+ private declare right_uniform_location: WebGLUniformLocation | null;
20
+ private declare top_uniform_location: WebGLUniformLocation | null;
21
+ private declare bot_uniform_location: WebGLUniformLocation | null;
22
+ private declare circle_radius_uniform_location: WebGLUniformLocation | null;
23
+ private declare size_uniform_location: WebGLUniformLocation | null;
24
+ private declare colour_uniform_location: WebGLUniformLocation | null;
25
+ private declare background_colour_uniform_location: WebGLUniformLocation | null;
26
+ protected override setupFragment(){
27
+ this.fragment_name = 'PathCentreCircleShader';
28
+ if(PathCentreCircleFragmentShader.shader){
29
+ this.program.addFragment(PathCentreCircleFragmentShader.shader)
30
+ }else{
31
+ throw new Error(`${this.fragment_name} not loaded`);
32
+ }
33
+ }
34
+ protected override addFragmentUniformLocations(): void{
35
+ this.left_uniform_location = this.program.getUniformLocation('u_left');
36
+ this.right_uniform_location = this.program.getUniformLocation('u_right');
37
+ this.top_uniform_location = this.program.getUniformLocation('u_top');
38
+ this.bot_uniform_location = this.program.getUniformLocation('u_bot');
39
+ this.circle_radius_uniform_location = this.program.getUniformLocation('u_circle_radius');
40
+ this.size_uniform_location = this.program.getUniformLocation('u_size');
41
+ this.colour_uniform_location = this.program.getUniformLocation('u_colour');
42
+ this.background_colour_uniform_location = this.program.getUniformLocation('u_background_colour');
43
+ }
44
+ setLeft(a: GLfloat){
45
+ this.program.setFloat(this.left_uniform_location!, a);
46
+ }
47
+ setRight(a: GLfloat){
48
+ this.program.setFloat(this.right_uniform_location!, a);
49
+ }
50
+ setTop(a: GLfloat){
51
+ this.program.setFloat(this.top_uniform_location!, a);
52
+ }
53
+ setBot(a: GLfloat){
54
+ this.program.setFloat(this.bot_uniform_location!, a);
55
+ }
56
+ setCircleRadius(a: GLfloat){
57
+ this.program.setFloat(this.circle_radius_uniform_location!, a);
58
+ }
59
+ setSize(a: GLfloat){
60
+ this.program.setFloat(this.size_uniform_location!, a);
61
+ }
62
+ setColour(a: GLfloat, b: GLfloat, c: GLfloat){
63
+ this.program.setFloat3(this.colour_uniform_location!, a, b, c);
64
+ }
65
+ setBackgroundColour(a: GLfloat, b: GLfloat, c: GLfloat){
66
+ this.program.setFloat3(this.background_colour_uniform_location!, a, b, c);
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,39 @@
1
+ import RectOutline from './../Source/rect_outline.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class RectOutlineFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(RectOutline)){
10
+ console.log('RectOutline: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function RectOutlineShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class RectOutline extends Base{
18
+ private declare outline_colour_uniform_location: WebGLUniformLocation | null;
19
+ private declare outline_ratio_uniform_location: WebGLUniformLocation | null;
20
+ protected override setupFragment(){
21
+ this.fragment_name = 'RectOutlineShader';
22
+ if(RectOutlineFragmentShader.shader){
23
+ this.program.addFragment(RectOutlineFragmentShader.shader)
24
+ }else{
25
+ throw new Error(`${this.fragment_name} not loaded`);
26
+ }
27
+ }
28
+ protected override addFragmentUniformLocations(): void{
29
+ this.outline_colour_uniform_location = this.program.getUniformLocation('u_outline_colour');
30
+ this.outline_ratio_uniform_location = this.program.getUniformLocation('u_outline_ratio');
31
+ }
32
+ setOutline_colour(a: GLfloat, b: GLfloat, c: GLfloat, d: GLfloat){
33
+ this.program.setFloat4(this.outline_colour_uniform_location!, a, b, c, d);
34
+ }
35
+ setOutline_ratio(a: GLfloat){
36
+ this.program.setFloat(this.outline_ratio_uniform_location!, a);
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,64 @@
1
+ import SolidPath from './../Source/solid_path.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class SolidPathFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(SolidPath)){
10
+ console.log('SolidPath: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function SolidPathShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class SolidPath extends Base{
18
+ private declare left_uniform_location: WebGLUniformLocation | null;
19
+ private declare right_uniform_location: WebGLUniformLocation | null;
20
+ private declare top_uniform_location: WebGLUniformLocation | null;
21
+ private declare bot_uniform_location: WebGLUniformLocation | null;
22
+ private declare size_uniform_location: WebGLUniformLocation | null;
23
+ private declare colour_uniform_location: WebGLUniformLocation | null;
24
+ private declare background_colour_uniform_location: WebGLUniformLocation | null;
25
+ protected override setupFragment(){
26
+ this.fragment_name = 'SolidPathShader';
27
+ if(SolidPathFragmentShader.shader){
28
+ this.program.addFragment(SolidPathFragmentShader.shader)
29
+ }else{
30
+ throw new Error(`${this.fragment_name} not loaded`);
31
+ }
32
+ }
33
+ protected override addFragmentUniformLocations(): void{
34
+ this.left_uniform_location = this.program.getUniformLocation('u_left');
35
+ this.right_uniform_location = this.program.getUniformLocation('u_right');
36
+ this.top_uniform_location = this.program.getUniformLocation('u_top');
37
+ this.bot_uniform_location = this.program.getUniformLocation('u_bot');
38
+ this.size_uniform_location = this.program.getUniformLocation('u_size');
39
+ this.colour_uniform_location = this.program.getUniformLocation('u_colour');
40
+ this.background_colour_uniform_location = this.program.getUniformLocation('u_background_colour');
41
+ }
42
+ setLeft(a: GLfloat){
43
+ this.program.setFloat(this.left_uniform_location!, a);
44
+ }
45
+ setRight(a: GLfloat){
46
+ this.program.setFloat(this.right_uniform_location!, a);
47
+ }
48
+ setTop(a: GLfloat){
49
+ this.program.setFloat(this.top_uniform_location!, a);
50
+ }
51
+ setBot(a: GLfloat){
52
+ this.program.setFloat(this.bot_uniform_location!, a);
53
+ }
54
+ setSize(a: GLfloat){
55
+ this.program.setFloat(this.size_uniform_location!, a);
56
+ }
57
+ setColour(a: GLfloat, b: GLfloat, c: GLfloat){
58
+ this.program.setFloat3(this.colour_uniform_location!, a, b, c);
59
+ }
60
+ setBackgroundColour(a: GLfloat, b: GLfloat, c: GLfloat){
61
+ this.program.setFloat3(this.background_colour_uniform_location!, a, b, c);
62
+ }
63
+ }
64
+ }
@@ -0,0 +1,54 @@
1
+ import SpriteSheet from './../Source/sprite_sheet.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class SpriteSheetFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(SpriteSheet)){
10
+ console.log('SpriteSheet: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function SpriteSheetShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class SpriteSheet extends Base{
18
+ private declare texture_id_uniform_location: WebGLUniformLocation | null;
19
+ private declare width_uniform_location: WebGLUniformLocation | null;
20
+ private declare height_uniform_location: WebGLUniformLocation | null;
21
+ private declare x_uniform_location: WebGLUniformLocation | null;
22
+ private declare y_uniform_location: WebGLUniformLocation | null;
23
+ protected override setupFragment(){
24
+ this.fragment_name = 'SpriteSheetShader';
25
+ if(SpriteSheetFragmentShader.shader){
26
+ this.program.addFragment(SpriteSheetFragmentShader.shader)
27
+ }else{
28
+ throw new Error(`${this.fragment_name} not loaded`);
29
+ }
30
+ }
31
+ protected override addFragmentUniformLocations(): void{
32
+ this.texture_id_uniform_location = this.program.getUniformLocation('u_texture_id');
33
+ this.width_uniform_location = this.program.getUniformLocation('u_width');
34
+ this.height_uniform_location = this.program.getUniformLocation('u_height');
35
+ this.x_uniform_location = this.program.getUniformLocation('u_x');
36
+ this.y_uniform_location = this.program.getUniformLocation('u_y');
37
+ }
38
+ setTextureId(i: GLint){
39
+ this.program.setInt(this.texture_id_uniform_location!, i);
40
+ }
41
+ setWidth(a: GLfloat){
42
+ this.program.setFloat(this.width_uniform_location!, a);
43
+ }
44
+ setHeight(a: GLfloat){
45
+ this.program.setFloat(this.height_uniform_location!, a);
46
+ }
47
+ setX(a: GLfloat){
48
+ this.program.setFloat(this.x_uniform_location!, a);
49
+ }
50
+ setY(a: GLfloat){
51
+ this.program.setFloat(this.y_uniform_location!, a);
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,62 @@
1
+ import SpriteSheetColour from './../Source/sprite_sheet_colour.frag?raw';
2
+ import * as Shader from './../../shader';
3
+ import * as WebGL from './../../../globals';
4
+
5
+ export class SpriteSheetColourFragmentShader{
6
+ static shader?: Shader.FragmentShader;
7
+ static load(){
8
+ if(this.shader == undefined){
9
+ this.shader = new Shader.FragmentShader();
10
+ if(!this.shader.addSource(SpriteSheetColour)){
11
+ console.log('SpriteSheetColour: fragment source not added');
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ export function SpriteSheetColourShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
18
+ return class SpriteSheetColour extends Base{
19
+ private declare texture_id_uniform_location: WebGLUniformLocation | null;
20
+ private declare width_uniform_location: WebGLUniformLocation | null;
21
+ private declare height_uniform_location: WebGLUniformLocation | null;
22
+ private declare x_uniform_location: WebGLUniformLocation | null;
23
+ private declare y_uniform_location: WebGLUniformLocation | null;
24
+ private declare colour_uniform_location: WebGLUniformLocation | null;
25
+ protected override setupFragment(){
26
+ this.fragment_name = 'SpriteSheetColourShader';
27
+ if(!SpriteSheetColourFragmentShader.shader){
28
+ SpriteSheetColourFragmentShader.load();
29
+ }
30
+ this.program.addFragment(SpriteSheetColourFragmentShader.shader!);
31
+ }
32
+ protected override addFragmentUniformLocations(): void{
33
+ this.texture_id_uniform_location = this.program.getUniformLocation('u_texture_id');
34
+ this.width_uniform_location = this.program.getUniformLocation('u_width');
35
+ this.height_uniform_location = this.program.getUniformLocation('u_height');
36
+ this.x_uniform_location = this.program.getUniformLocation('u_x');
37
+ this.y_uniform_location = this.program.getUniformLocation('u_y');
38
+ this.colour_uniform_location = this.program.getUniformLocation('u_colour');
39
+ }
40
+ setTextureId(i: GLint){
41
+ this.program.setInt(this.texture_id_uniform_location!, i);
42
+ }
43
+ setWidth(a: GLfloat){
44
+ this.program.setFloat(this.width_uniform_location!, a);
45
+ }
46
+ setHeight(a: GLfloat){
47
+ this.program.setFloat(this.height_uniform_location!, a);
48
+ }
49
+ setX(a: GLfloat){
50
+ this.program.setFloat(this.x_uniform_location!, a);
51
+ }
52
+ setY(a: GLfloat){
53
+ this.program.setFloat(this.y_uniform_location!, a);
54
+ }
55
+ setColour(a: GLfloat, b: GLfloat, c: GLfloat){
56
+ this.program.setFloat3(this.colour_uniform_location!, a, b, c);
57
+ }
58
+ setColourFromColourRGB(colour: WebGL.Colour.ColourRGB){
59
+ this.program.setFloat3(this.colour_uniform_location!, colour.red, colour.green, colour.blue);
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,34 @@
1
+ import Texture from './../Source/texture.frag?raw';
2
+ import * as Shader from './../../shader';
3
+
4
+ export class TextureFragmentShader{
5
+ static shader?: Shader.FragmentShader;
6
+ static load(){
7
+ if(this.shader == undefined){
8
+ this.shader = new Shader.FragmentShader();
9
+ if(!this.shader.addSource(Texture)){
10
+ console.log('Texture: fragment source not added');
11
+ }
12
+ }
13
+ }
14
+ }
15
+
16
+ export function TextureShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
17
+ return class Texture extends Base{
18
+ private declare texture_id_uniform_location: WebGLUniformLocation | null;
19
+ protected override setupFragment(){
20
+ this.fragment_name = 'TextureShader';
21
+ if(TextureFragmentShader.shader){
22
+ this.program.addFragment(TextureFragmentShader.shader)
23
+ }else{
24
+ throw new Error(`${this.fragment_name} not loaded`);
25
+ }
26
+ }
27
+ protected override addFragmentUniformLocations(): void{
28
+ this.texture_id_uniform_location = this.program.getUniformLocation('u_texture_id');
29
+ }
30
+ setTextureId(i: GLint){
31
+ this.program.setInt(this.texture_id_uniform_location!, i);
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,19 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform vec2 u_centre;
7
+ uniform float u_radius;
8
+ uniform vec3 u_circle_colour;
9
+ uniform vec3 u_background_colour;
10
+
11
+ void main(){
12
+ vec2 middle = vec2(u_centre);
13
+
14
+ float circle = step(u_radius, distance(middle, v_relative));
15
+
16
+ vec3 col = circle*u_background_colour + (1.0-circle)*u_circle_colour;
17
+
18
+ gl_FragColor = vec4(col, 1.0);
19
+ }
@@ -0,0 +1,15 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform vec2 u_centre;
7
+ uniform float u_radius;
8
+ uniform vec3 u_circle_colour; //colour
9
+
10
+ void main(){
11
+ vec2 middle = vec2(u_centre);
12
+ float circle = step(u_radius, distance(middle, v_relative));
13
+ float in_circle = 1.0-circle;
14
+ gl_FragColor = vec4(u_circle_colour, in_circle);
15
+ }
@@ -0,0 +1,23 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform vec2 u_centre;
7
+ uniform float u_radius;
8
+ uniform float u_outline_radius;
9
+
10
+ uniform vec4 u_outline_colour;
11
+ uniform vec4 u_background_colour;
12
+
13
+ void main(){
14
+ vec2 middle = vec2(u_centre);
15
+ float d = distance(middle, v_relative);
16
+ float circle = step(d, u_radius);
17
+ float centre_circle = step(d, u_radius-u_outline_radius);
18
+
19
+ float in_outline = circle-centre_circle;
20
+
21
+ vec4 col = u_outline_colour*in_outline;
22
+ gl_FragColor = col;
23
+ }
@@ -0,0 +1,9 @@
1
+ precision mediump float;
2
+
3
+
4
+
5
+ uniform vec3 colour;
6
+
7
+ void main(){
8
+ gl_FragColor = vec4(colour, 1.0);
9
+ }
@@ -0,0 +1,7 @@
1
+ precision mediump float;
2
+
3
+ uniform vec4 colour; //coloura
4
+
5
+ void main(){
6
+ gl_FragColor = vec4(colour);
7
+ }
@@ -0,0 +1,5 @@
1
+ precision mediump float;
2
+
3
+ void main(){
4
+ gl_FragColor = vec4(1, 0, 0.5, 1);
5
+ }
@@ -0,0 +1,15 @@
1
+ import Colour from './colour.frag?raw';
2
+ import Fragment from './fragment.frag?raw';
3
+ import BasicCircle from './circle.frag?raw';
4
+ import OutlineCircle from './circle_outline.frag?raw';
5
+ import OutlineRect from './rect_outline.frag?raw';
6
+ import SolidLine from './line.frag?raw';
7
+ import SolidPath from './solid_path.frag?raw';
8
+
9
+ export const colour = Colour;
10
+ export const simple = Fragment;
11
+ export const circle = BasicCircle;
12
+ export const circle_outline = OutlineCircle;
13
+ export const rect_outline = OutlineRect;
14
+ export const solid_line = SolidLine;
15
+ export const solid_path = SolidPath;
@@ -0,0 +1,12 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform float u_thickness;
7
+ uniform vec3 u_equation;
8
+
9
+ void main(){
10
+ float in_line = 1.0-step(u_thickness, abs(u_equation.x*v_relative.x + u_equation.y*v_relative.y + u_equation.z));
11
+ gl_FragColor = vec4(vec3(1.0), in_line);
12
+ }
@@ -0,0 +1,36 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform vec3 u_left_colour;
7
+ uniform vec3 u_right_colour;
8
+ uniform vec3 u_top_colour;
9
+ uniform vec3 u_bot_colour;
10
+ uniform vec3 u_mid_colour;
11
+ uniform float u_circle_radius;
12
+ uniform float u_size; // between 0 and 0.5
13
+ uniform vec3 u_background_colour;
14
+
15
+ void main(){
16
+ vec2 uv = v_relative;
17
+ float sz = u_size/2.;
18
+
19
+ float vertical = step(abs(0.5-uv.x), sz);
20
+ float horizontal = step(abs(0.5-uv.y), sz);
21
+
22
+ vec2 middle = vec2(0.5, 0.5);
23
+ float not_inside_circle = step(u_circle_radius, distance(middle, uv));
24
+ float inside_circle = 1.0 - not_inside_circle;
25
+
26
+ float top = not_inside_circle*vertical*step(0.5+sz, uv.y);
27
+ float bottom = not_inside_circle*vertical*step(uv.y, 0.5-sz);
28
+ float left = not_inside_circle*horizontal*step(uv.x, 0.5-sz);
29
+ float right = not_inside_circle*horizontal*step(0.5+sz, uv.x);
30
+
31
+ float background = 1.0-clamp(top+bottom+left+right+inside_circle, 0.0, 1.0);
32
+
33
+ vec3 colour = top*u_top_colour+bottom*u_bot_colour+left*u_left_colour+right*u_right_colour+inside_circle*u_mid_colour+background*u_background_colour;
34
+
35
+ gl_FragColor = vec4(colour, 1.0);
36
+ }
@@ -0,0 +1,34 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform vec3 u_left_colour;
7
+ uniform vec3 u_right_colour;
8
+ uniform vec3 u_top_colour;
9
+ uniform vec3 u_bot_colour;
10
+ uniform vec3 u_mid_colour;
11
+ uniform float u_circle_radius;
12
+ uniform float u_size; // between 0 and 0.5
13
+ uniform vec3 u_background_colour;
14
+
15
+ void main(){
16
+ vec2 uv = v_relative;
17
+ float sz = u_size/2.;
18
+
19
+ float vertical = step(abs(0.5-uv.x), sz);
20
+ float horizontal = step(abs(0.5-uv.y), sz);
21
+
22
+ float top = vertical*step(0.5+sz, uv.y);
23
+ float bottom = vertical*step(uv.y, 0.5-sz);
24
+ float left = horizontal*step(uv.x, 0.5-sz);
25
+ float right = horizontal*step(0.5+sz, uv.x);
26
+
27
+ float mid = horizontal*vertical;
28
+
29
+ float background = 1.0-(top+bottom+left+right+mid);
30
+
31
+ vec3 colour = top*u_top_colour+bottom*u_bot_colour+left*u_left_colour+right*u_right_colour+mid*u_mid_colour+background*u_background_colour;
32
+
33
+ gl_FragColor = vec4(colour, 1.0);
34
+ }
@@ -0,0 +1,29 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform float u_left;
7
+ uniform float u_right;
8
+ uniform float u_top;
9
+ uniform float u_bot;
10
+ uniform float u_circle_radius;
11
+ uniform float u_size; // between 0 and 0.5
12
+ uniform vec3 u_colour;
13
+ uniform vec3 u_background_colour;
14
+
15
+ void main(){
16
+ vec2 uv = v_relative;
17
+ float sz = u_size/2.;
18
+
19
+ float inside_top = step(abs(0.5-uv.x), sz)*step(0.5-sz, uv.y)*u_top;
20
+ float inside_bot = step(abs(0.5-uv.x), sz)*step(uv.y, 0.5+sz)*u_bot;
21
+ float inside_left = step(abs(0.5-uv.y), sz)*step(uv.x, 0.5-sz)*u_left;
22
+ float inside_right = step(abs(0.5-uv.y), sz)*step(0.5-sz, uv.x)*u_right;
23
+
24
+ vec2 middle = vec2(0.5, 0.5);
25
+ float inside_circle = 1.0-step(u_circle_radius, distance(middle, v_relative));
26
+ float inside = clamp(inside_top+inside_bot+inside_left+inside_right+inside_circle, 0.0, 1.0);
27
+
28
+ gl_FragColor = vec4(inside*u_colour+(1.0-inside)*u_background_colour, 1.0);
29
+ }
@@ -0,0 +1,20 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform vec4 u_outline_colour;
7
+ uniform float u_outline_ratio;
8
+
9
+ void main(){
10
+ float in_x = 1.0-step(u_outline_ratio, v_relative.x)*step(v_relative.x, 1.0-u_outline_ratio);
11
+ float in_y = 1.0-step(u_outline_ratio, v_relative.y)*step(v_relative.y, 1.0-u_outline_ratio);
12
+ float inside = step(1.0, in_x+in_y);
13
+
14
+
15
+ gl_FragColor = inside*u_outline_colour;
16
+
17
+ //gl_FragColor = vec4(v_relative.x,0.0,0.0,1.0);
18
+
19
+
20
+ }
@@ -0,0 +1,24 @@
1
+ precision mediump float;
2
+
3
+ varying vec2 v_position;
4
+ varying vec2 v_relative;
5
+
6
+ uniform float u_left;
7
+ uniform float u_right;
8
+ uniform float u_top;
9
+ uniform float u_bot;
10
+ uniform float u_size; // between 0 and 0.5
11
+ uniform vec3 u_colour;
12
+ uniform vec3 u_background_colour;
13
+
14
+ void main(){
15
+ vec2 uv = v_relative;
16
+ float sz = u_size/2.;
17
+ float inside_top = step(abs(0.5-uv.x), sz)*step(0.5-sz, uv.y)*u_top;
18
+ float inside_bot = step(abs(0.5-uv.x), sz)*step(uv.y, 0.5+sz)*u_bot;
19
+ float inside_left = step(abs(0.5-uv.y), sz)*step(uv.x, 0.5-sz)*u_left;
20
+ float inside_right = step(abs(0.5-uv.y), sz)*step(0.5-sz, uv.x)*u_right;
21
+ float inside = clamp(inside_top+inside_bot+inside_left+inside_right, 0.0, 1.0);
22
+
23
+ gl_FragColor = vec4(inside*u_colour+(1.0-inside)*u_background_colour, 1.0);
24
+ }