q5 4.3.0 → 4.4.1

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 (5) hide show
  1. package/deno.json +1 -1
  2. package/package.json +1 -1
  3. package/q5.d.ts +51 -21
  4. package/q5.js +455 -110
  5. package/q5.min.js +2 -2
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q5/q5",
3
- "version": "4.3.0",
3
+ "version": "4.4.1",
4
4
  "license": "LGPL-3.0-only",
5
5
  "description": "Beginner friendly graphics powered by WebGPU, optimized for interactive art!",
6
6
  "author": "quinton-ashley",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q5",
3
- "version": "4.3.0",
3
+ "version": "4.4.1",
4
4
  "description": "Beginner friendly graphics powered by WebGPU, optimized for interactive art!",
5
5
  "author": "quinton-ashley",
6
6
  "contributors": [
package/q5.d.ts CHANGED
@@ -133,6 +133,8 @@ declare global {
133
133
 
134
134
  /** 🧑‍🎨
135
135
  * Draws a line on the canvas.
136
+ *
137
+ * To draw lines with rounded stroke caps, use `capsule` instead.
136
138
  * @param {number} x1 x-coordinate of the first point
137
139
  * @param {number} y1 y-coordinate of the first point
138
140
  * @param {number} x2 x-coordinate of the second point
@@ -3820,33 +3822,51 @@ declare global {
3820
3822
  function curveDetail(val: number): void;
3821
3823
 
3822
3824
  /** 🖌
3823
- * Starts storing vertices for a convex shape.
3825
+ * Starts storing vertices for a shape.
3824
3826
  */
3825
3827
  function beginShape(): void;
3826
3828
 
3827
3829
  /** 🖌
3828
- * Ends storing vertices for a convex shape.
3830
+ * Ends storing vertices for a shape.
3831
+ * @param {boolean} [close] whether to close the shape by connecting the last vertex to the first vertex, default is false
3829
3832
  */
3830
3833
  function endShape(): void;
3831
3834
 
3832
- /** 🖌
3833
- * Starts storing vertices for a contour.
3834
- *
3835
- * Not available in q5 WebGPU.
3836
- */
3837
- function beginContour(): void;
3838
-
3839
- /** 🖌
3840
- * Ends storing vertices for a contour.
3841
- *
3842
- * Not available in q5 WebGPU.
3843
- */
3844
- function endContour(): void;
3845
-
3846
3835
  /** 🖌
3847
3836
  * Specifies a vertex in a shape.
3837
+ *
3838
+ * Each vertex can have its own fill color. Useful for creating gradients.
3839
+ *
3840
+ * Note that shapes without a stroke will be drawn using the shapes shader. Stroked shapes will be drawn using the more complex stroked shapes shader.
3848
3841
  * @param {number} x x-coordinate
3849
3842
  * @param {number} y y-coordinate
3843
+ * @example
3844
+ * await Canvas(200);
3845
+ *
3846
+ * noStroke();
3847
+ *
3848
+ * beginShape();
3849
+ * fill(1, 0, 0);
3850
+ * vertex(-80, -80);
3851
+ * vertex(40, -60);
3852
+ * fill(0, 0, 1);
3853
+ * vertex(80, 60);
3854
+ * vertex(-60, 80);
3855
+ * endShape(true);
3856
+ * @example
3857
+ * await Canvas(200);
3858
+ *
3859
+ * stroke(1, 0.5);
3860
+ * strokeWeight(20);
3861
+ *
3862
+ * beginShape();
3863
+ * fill(1, 0, 0);
3864
+ * vertex(-80, -80);
3865
+ * vertex(40, -60);
3866
+ * fill(0, 0, 1);
3867
+ * vertex(80, 60);
3868
+ * vertex(-60, 80);
3869
+ * endShape(true);
3850
3870
  */
3851
3871
  function vertex(x: number, y: number): void;
3852
3872
 
@@ -3907,6 +3927,20 @@ declare global {
3907
3927
  */
3908
3928
  function quad(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
3909
3929
 
3930
+ /** 🖌
3931
+ * Starts storing vertices for a contour.
3932
+ *
3933
+ * Not available in q5 WebGPU.
3934
+ */
3935
+ function beginContour(): void;
3936
+
3937
+ /** 🖌
3938
+ * Ends storing vertices for a contour.
3939
+ *
3940
+ * Not available in q5 WebGPU.
3941
+ */
3942
+ function endContour(): void;
3943
+
3910
3944
  // ⚡ shaders
3911
3945
 
3912
3946
  /**
@@ -3917,11 +3951,7 @@ declare global {
3917
3951
  /** ⚡
3918
3952
  * Creates a shader that q5's WebGPU renderer can use.
3919
3953
  *
3920
- * If `type` is not specified, this function customizes a copy of the [default shapes shader](https://github.com/q5js/q5.js/blob/main/src/shaders/shapes.wgsl), which affects the following functions:
3921
- *
3922
- * `triangle`, `quad`, `plane`,
3923
- * `curve`, `bezier`, `beginShape`/`endShape`,
3924
- * and `background` (unless an image is used).
3954
+ * If `type` is not specified, this function customizes a copy of the [default shapes shader](https://github.com/q5js/q5.js/blob/main/src/shaders/shapes.wgsl), which affects these functions: `plane`, `line`, and `endShape` (only for shapes drawn without a stroke).
3925
3955
  *
3926
3956
  * For more information on the vertex and fragment function
3927
3957
  * input parameters, data, and helper functions made available for use