q5 4.6.2 → 4.6.3
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.
- package/package.json +2 -2
- package/q5.d.ts +16 -9
- package/q5.js +23 -4
- package/q5.min.js +1 -1
- package/q5.min.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q5",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.3",
|
|
4
4
|
"description": "Beginner friendly graphics powered by WebGPU, optimized for interactive art!",
|
|
5
5
|
"author": "quinton-ashley",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dist": "bun bundle && bun min",
|
|
47
47
|
"tests": "jest test",
|
|
48
48
|
"bld": "node lang/build.js",
|
|
49
|
-
"
|
|
49
|
+
"types": "node lang/types.js",
|
|
50
50
|
"v": "npm version patch --force",
|
|
51
51
|
"V": "npm version minor --force",
|
|
52
52
|
"version": "git add -A",
|
package/q5.d.ts
CHANGED
|
@@ -1875,10 +1875,18 @@ declare global {
|
|
|
1875
1875
|
function blendMode(val: string): void;
|
|
1876
1876
|
|
|
1877
1877
|
/** 💅
|
|
1878
|
-
* Set the line cap style to `
|
|
1879
|
-
*
|
|
1880
|
-
* Not available in q5 WebGPU.
|
|
1878
|
+
* Set the line cap style to `SQUARE` or `PROJECT`.
|
|
1881
1879
|
* @param {CanvasLineCap} val line cap style
|
|
1880
|
+
* @example
|
|
1881
|
+
* await Canvas(200);
|
|
1882
|
+
* background(0.8);
|
|
1883
|
+
* strokeWeight(20);
|
|
1884
|
+
*
|
|
1885
|
+
* strokeCap(SQUARE);
|
|
1886
|
+
* line(-50, -25, 50, -25);
|
|
1887
|
+
*
|
|
1888
|
+
* strokeCap(PROJECT);
|
|
1889
|
+
* line(-50, 25, 50, 25);
|
|
1882
1890
|
*/
|
|
1883
1891
|
function strokeCap(val: CanvasLineCap): void;
|
|
1884
1892
|
|
|
@@ -4073,12 +4081,13 @@ declare global {
|
|
|
4073
4081
|
/** ⚡
|
|
4074
4082
|
* Creates a shader that q5 can use to draw frames.
|
|
4075
4083
|
*
|
|
4076
|
-
* You must create a canvas before using this function.
|
|
4077
|
-
*
|
|
4078
4084
|
* Use this function to customize a copy of the
|
|
4079
4085
|
* [default frame shader](https://github.com/q5js/q5.js/blob/main/src/shaders/frame.wgsl).
|
|
4080
4086
|
* @example
|
|
4081
|
-
* await Canvas(200);
|
|
4087
|
+
* await Canvas(200, 400);
|
|
4088
|
+
* stroke(1);
|
|
4089
|
+
* strokeWeight(8);
|
|
4090
|
+
* strokeCap(PROJECT);
|
|
4082
4091
|
*
|
|
4083
4092
|
* let boxy = createFrameShader(`
|
|
4084
4093
|
* @fragment
|
|
@@ -4090,8 +4099,6 @@ declare global {
|
|
|
4090
4099
|
* }`);
|
|
4091
4100
|
*
|
|
4092
4101
|
* q5.draw = function () {
|
|
4093
|
-
* stroke(1);
|
|
4094
|
-
* strokeWeight(8);
|
|
4095
4102
|
* line(mouseX, mouseY, pmouseX, pmouseY);
|
|
4096
4103
|
* mouseIsPressed ? resetShaders() : shader(boxy);
|
|
4097
4104
|
* };
|
|
@@ -4106,7 +4113,7 @@ declare global {
|
|
|
4106
4113
|
* @param {string} code WGSL shader code excerpt
|
|
4107
4114
|
* @returns {GPUShaderModule} a shader program
|
|
4108
4115
|
* @example
|
|
4109
|
-
* await Canvas(200);
|
|
4116
|
+
* await Canvas(200, 400);
|
|
4110
4117
|
* imageMode(CENTER);
|
|
4111
4118
|
*
|
|
4112
4119
|
* let logo = loadImage('/q5js_logo.avif');
|
package/q5.js
CHANGED
|
@@ -7326,10 +7326,29 @@ fn vertexMain(v: VertexParams) -> FragParams {
|
|
|
7326
7326
|
|
|
7327
7327
|
let len = Math.sqrt(sqLen),
|
|
7328
7328
|
ratio = hsw / len,
|
|
7329
|
-
nx = -dy * ratio,
|
|
7330
|
-
ny = dx * ratio
|
|
7331
|
-
|
|
7332
|
-
|
|
7329
|
+
nx = -dy * ratio, // line thickness
|
|
7330
|
+
ny = dx * ratio,
|
|
7331
|
+
ex = 0,
|
|
7332
|
+
ey = 0;
|
|
7333
|
+
|
|
7334
|
+
if (_strokeCap[0] === 's') {
|
|
7335
|
+
// 'square' PROJECT
|
|
7336
|
+
ex = ny;
|
|
7337
|
+
ey = -nx;
|
|
7338
|
+
}
|
|
7339
|
+
|
|
7340
|
+
addQuad(
|
|
7341
|
+
x1 - ex + nx,
|
|
7342
|
+
y1 - ey + ny,
|
|
7343
|
+
x1 - ex - nx,
|
|
7344
|
+
y1 - ey - ny,
|
|
7345
|
+
x2 + ex - nx,
|
|
7346
|
+
y2 + ey - ny,
|
|
7347
|
+
x2 + ex + nx,
|
|
7348
|
+
y2 + ey + ny,
|
|
7349
|
+
strokeIdx,
|
|
7350
|
+
matrixIdx
|
|
7351
|
+
);
|
|
7333
7352
|
};
|
|
7334
7353
|
|
|
7335
7354
|
/* ELLIPSE */
|