q5 2.26.0 → 2.27.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 (5) hide show
  1. package/deno.json +1 -1
  2. package/package.json +1 -1
  3. package/q5.d.ts +227 -36
  4. package/q5.js +154 -113
  5. package/q5.min.js +1 -1
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q5/q5",
3
- "version": "2.26.0",
3
+ "version": "2.27.0",
4
4
  "license": "LGPL-3.0",
5
5
  "description": "Beginner friendly graphics powered by WebGPU and 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": "2.26.0",
3
+ "version": "2.27.0",
4
4
  "description": "Beginner friendly graphics powered by WebGPU and optimized for interactive art!",
5
5
  "author": "quinton-ashley",
6
6
  "contributors": [
package/q5.d.ts CHANGED
@@ -924,7 +924,7 @@ let c = color(200, 50);
924
924
  function draw() {
925
925
  background(c);
926
926
  circle(mouseX, mouseY, 50);
927
- c.g = (c.g + 1) % 255;
927
+ c.g = (c.g + 1) % 256;
928
928
  }
929
929
  * @example
930
930
  let q = await Q5.WebGPU();
@@ -1359,28 +1359,114 @@ point(125, 50);
1359
1359
  function blendMode(val: string): void;
1360
1360
 
1361
1361
  /** 🧑‍🎨
1362
- * Set the line cap style to `ROUND`, `SQUARE`, or `BUTT`.
1362
+ * Set the line cap style to `ROUND`, `SQUARE`, or `PROJECT`.
1363
1363
  * @param {CanvasLineCap} val line cap style
1364
- */
1364
+ * @example
1365
+ createCanvas(200);
1366
+ background(200);
1367
+ strokeWeight(20);
1368
+
1369
+ strokeCap(ROUND);
1370
+ line(50, 50, 150, 50);
1371
+
1372
+ strokeCap(SQUARE);
1373
+ line(50, 100, 150, 100);
1374
+
1375
+ strokeCap(PROJECT);
1376
+ line(50, 150, 150, 150);
1377
+ */
1365
1378
  function strokeCap(val: CanvasLineCap): void;
1366
1379
 
1367
1380
  /** 🧑‍🎨
1368
1381
  * Set the line join style to `ROUND`, `BEVEL`, or `MITER`.
1369
1382
  * @param {CanvasLineJoin} val line join style
1370
- */
1383
+ * @example
1384
+ createCanvas(200);
1385
+ background(200);
1386
+ strokeWeight(10);
1387
+
1388
+ strokeJoin(ROUND);
1389
+ triangle(50, 20, 150, 20, 50, 70);
1390
+
1391
+ strokeJoin(BEVEL);
1392
+ triangle(150, 50, 50, 100, 150, 150);
1393
+
1394
+ strokeJoin(MITER);
1395
+ triangle(50, 130, 150, 180, 50, 180);
1396
+ */
1371
1397
  function strokeJoin(val: CanvasLineJoin): void;
1372
1398
 
1373
1399
  /** 🧑‍🎨
1374
- * Set ellipse mode to `CENTER`, `RADIUS`, or `CORNER`.
1400
+ * Set to `CORNER`, `CENTER`, `RADIUS`, or `CORNERS`.
1401
+ *
1402
+ * Changes how the first four inputs to
1403
+ * `rect` and `square` are interpreted.
1404
+ * @param {string} val rectangle mode
1405
+ * @example
1406
+ createCanvas(200, 100);
1407
+ background(200);
1408
+
1409
+ rectMode(CORNER);
1410
+ rect(50, 25, 100, 50);
1411
+ * @example
1412
+ createCanvas(200, 100);
1413
+ background(200);
1414
+
1415
+ rectMode(CENTER);
1416
+ rect(100, 50, 100, 50);
1417
+ * @example
1418
+ createCanvas(200, 100);
1419
+ background(200);
1420
+
1421
+ rectMode(RADIUS);
1422
+ rect(100, 50, 50, 25);
1423
+ * @example
1424
+ createCanvas(200, 100);
1425
+ background(200);
1426
+
1427
+ rectMode(CORNERS);
1428
+ rect(50, 25, 150, 75);
1429
+ */
1430
+ function rectMode(val: string): void;
1431
+
1432
+ /** 🧑‍🎨
1433
+ * Set to `CENTER`, `RADIUS`, `CORNER`, or `CORNERS`.
1434
+ *
1435
+ * Changes how the first four inputs to
1436
+ * `ellipse`, `circle`, and `arc` are interpreted.
1375
1437
  * @param {string} val ellipse mode
1438
+ * @example
1439
+ createCanvas(200, 100);
1440
+ background(200);
1441
+
1442
+ ellipseMode(CENTER);
1443
+ ellipse(100, 50, 100, 50);
1444
+ * @example
1445
+ createCanvas(200, 100);
1446
+ background(200);
1447
+
1448
+ ellipseMode(RADIUS);
1449
+ ellipse(100, 50, 50, 25);
1450
+ * @example
1451
+ createCanvas(200, 100);
1452
+ background(200);
1453
+
1454
+ ellipseMode(CORNER);
1455
+ ellipse(50, 25, 100, 50);
1456
+ * @example
1457
+ createCanvas(200, 100);
1458
+ background(200);
1459
+
1460
+ ellipseMode(CORNERS);
1461
+ ellipse(50, 25, 150, 75);
1376
1462
  */
1377
1463
  function ellipseMode(val: string): void;
1378
1464
 
1465
+
1379
1466
  /** 🧑‍🎨
1380
- * Set the rectangle mode to `CORNER`, `CORNERS`, `RADIUS`, or `CENTER`.
1381
- * @param {string} val rectangle mode
1467
+ * Draws a curve.
1382
1468
  */
1383
- function rectMode(val: string): void;
1469
+ function curve( x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): void;
1384
1470
 
1385
1471
  /** 🧑‍🎨
1386
1472
  * Sets the amount of straight line segments used to make a curve.
@@ -1389,8 +1475,13 @@ point(125, 50);
1389
1475
  * @param {number} val curve detail level, default is 20
1390
1476
  * @example
1391
1477
  await Q5.WebGPU();
1392
- curveDetail(2);
1393
- circle(100, 100, 80);
1478
+
1479
+ curveDetail(4);
1480
+
1481
+ strokeWeight(10);
1482
+ stroke(0, 1, 1);
1483
+ noFill();
1484
+ curve(-100, -200, -50, 0, 50, 0, 100, -200);
1394
1485
  */
1395
1486
  function curveDetail(val: number): void;
1396
1487
 
@@ -1519,6 +1610,19 @@ circle(100, 100, 80);
1519
1610
  */
1520
1611
  function inStroke(x: number, y: number): boolean;
1521
1612
 
1613
+ /** 🧑‍🎨
1614
+ */
1615
+ const CORNER: 'corner';
1616
+
1617
+ /** 🧑‍🎨
1618
+ */
1619
+ const RADIUS: 'radius';
1620
+
1621
+ /** 🧑‍🎨
1622
+ */
1623
+ const CORNERS: 'corners';
1624
+
1625
+
1522
1626
  // 🌆 image
1523
1627
 
1524
1628
  /** 🌆
@@ -1579,9 +1683,10 @@ function draw() {
1579
1683
 
1580
1684
  /** 🌆
1581
1685
  * Sets the image mode, which determines the position and alignment of images drawn on the canvas.
1582
- * `CORNER`: (default) images will be drawn from the top-left corner
1583
- * `CORNERS`: images will be drawn from the top-left to the bottom-right corner
1584
- * `CENTER`: images will be drawn centered at (dx, dy)
1686
+ *
1687
+ * - `CORNER`: (default) images will be drawn from the top-left corner
1688
+ * - `CORNERS`: images will be drawn from the top-left to the bottom-right corner
1689
+ * - `CENTER`: images will be drawn centered at (dx, dy)
1585
1690
  * @param {string} mode
1586
1691
  * @example
1587
1692
  createCanvas(200);
@@ -2202,6 +2307,16 @@ text(nf(PI, 4, 5), 10, 60);
2202
2307
 
2203
2308
  // 🖲️ input
2204
2309
 
2310
+ /** 🖲️
2311
+ * Note that input responses inside `draw` can be delayed by
2312
+ * up to one frame cycle: from the exact moment an input event occurs
2313
+ * to the next time a frame is drawn.
2314
+ *
2315
+ * Play sounds or trigger other non-visual feedback immediately
2316
+ * by responding to input events inside functions like
2317
+ * `mousePressed` and `keyPressed`.
2318
+ */
2319
+
2205
2320
  /** 🖲️
2206
2321
  * Current X position of the mouse.
2207
2322
  * @example
@@ -2257,23 +2372,73 @@ function draw() {
2257
2372
  let mouseIsPressed: boolean;
2258
2373
 
2259
2374
  /** 🖲️
2260
- * Define this function to respond to mouse events immediately.
2261
- *
2262
- * There can be a delay of up to one frame between a mouse event
2263
- * and the next time the `draw` function is run.
2264
- *
2265
- * Useful for playing sounds.
2375
+ * Define this function to respond to mouse down events.
2266
2376
  * @example
2267
2377
  createCanvas(200);
2378
+ let gray = 95;
2268
2379
 
2269
- let gray = 100;
2270
2380
  function mousePressed() {
2271
- background(gray);
2272
- gray += 10;
2381
+ background(gray % 256);
2382
+ gray += 40;
2273
2383
  }
2274
2384
  */
2275
2385
  function mousePressed(): void;
2276
2386
 
2387
+ /** 🖲️
2388
+ * Define this function to respond to mouse up events.
2389
+ * @example
2390
+ createCanvas(200);
2391
+ let gray = 95;
2392
+
2393
+ function mouseReleased() {
2394
+ background(gray % 256);
2395
+ gray += 40;
2396
+ }
2397
+ */
2398
+ function mouseReleased(): void;
2399
+
2400
+ /** 🖲️
2401
+ * Define this function to respond to mouse move events.
2402
+ * @example
2403
+ createCanvas(200);
2404
+ let gray = 95;
2405
+
2406
+ function mouseMoved() {
2407
+ background(gray % 256);
2408
+ gray++;
2409
+ }
2410
+ */
2411
+ function mouseMoved(): void;
2412
+
2413
+ /** 🖲️
2414
+ * Define this function to respond to mouse drag events.
2415
+ *
2416
+ * Dragging the mouse is defined as moving the mouse
2417
+ * while a mouse button is pressed.
2418
+ * @example
2419
+ createCanvas(200);
2420
+ let gray = 95;
2421
+
2422
+ function mouseDragged() {
2423
+ background(gray % 256);
2424
+ gray++;
2425
+ }
2426
+ */
2427
+ function mouseDragged(): void;
2428
+
2429
+ /** 🖲️
2430
+ * Define this function to respond to mouse double click events.
2431
+ * @example
2432
+ createCanvas(200);
2433
+ let gray = 95;
2434
+
2435
+ function doubleClicked() {
2436
+ background(gray % 256);
2437
+ gray += 40;
2438
+ }
2439
+ */
2440
+ function doubleClicked(): void;
2441
+
2277
2442
  /** 🖲️
2278
2443
  * The name of the last key pressed.
2279
2444
  * @example
@@ -2296,7 +2461,8 @@ function draw() {
2296
2461
  let keyIsPressed: boolean;
2297
2462
 
2298
2463
  /** 🖲️
2299
- * Returns true if the user is pressing the specified key, false otherwise. Accepts case-insensitive key names.
2464
+ * Returns true if the user is pressing the specified key, false
2465
+ * otherwise. Accepts case-insensitive key names.
2300
2466
  * @param {string} key key to check
2301
2467
  * @returns {boolean} true if the key is pressed, false otherwise
2302
2468
  * @example
@@ -2311,23 +2477,31 @@ function draw() {
2311
2477
  function keyIsDown(key: string): boolean;
2312
2478
 
2313
2479
  /** 🖲️
2314
- * Define this function to respond to key press events immediately.
2315
- *
2316
- * There can be a delay of up to one frame between a key press event
2317
- * and the next time the `draw` function is run.
2318
- *
2319
- * Useful for playing sounds.
2480
+ * Define this function to respond to key down events.
2320
2481
  * @example
2321
- createCanvas(200, 100);
2482
+ createCanvas(200);
2322
2483
 
2323
- let gray = 100;
2484
+ let gray = 95;
2324
2485
  function keyPressed() {
2325
- background(gray);
2326
- gray += 10;
2486
+ background(gray % 256);
2487
+ gray += 40;
2327
2488
  }
2328
2489
  */
2329
2490
  function keyPressed(): void;
2330
2491
 
2492
+ /** 🖲️
2493
+ * Define this function to respond to key up events.
2494
+ * @example
2495
+ createCanvas(200);
2496
+
2497
+ let gray = 95;
2498
+ function keyReleased() {
2499
+ background(gray % 256);
2500
+ gray += 40;
2501
+ }
2502
+ */
2503
+ function keyReleased(): void;
2504
+
2331
2505
  /** 🖲️
2332
2506
  * Array of current touches, each touch being an object with
2333
2507
  * id, x, and y properties.
@@ -2387,12 +2561,29 @@ function mouseWheel(e) {
2387
2561
  function mouseWheel(event: any): void;
2388
2562
 
2389
2563
  /** 🖲️
2390
- * Requests that the pointer be locked to the document body, hiding the cursor and allowing for unlimited movement.
2564
+ * Requests that the pointer be locked to the document body, hiding
2565
+ * the cursor and allowing for unlimited movement.
2566
+ *
2567
+ * Operating systems enable mouse acceleration by default, which is useful when you sometimes want slow precise movement (think about you might use a graphics package), but also want to move great distances with a faster mouse movement (think about scrolling, and selecting several files). For some games however, raw mouse input data is preferred for controlling camera rotation — where the same distance movement, fast or slow, results in the same rotation.
2568
+ * @param {boolean} unadjustedMovement set to true to disable OS-level mouse acceleration and access raw mouse input
2569
+ * @example
2570
+ function draw() {
2571
+ circle(mouseX / 10, mouseY / 10, 10);
2572
+ }
2573
+
2574
+ function doubleClicked() {
2575
+ if (!document.pointerLockElement) {
2576
+ requestPointerLock();
2577
+ } else {
2578
+ exitPointerLock();
2579
+ }
2580
+ }
2391
2581
  */
2392
- function requestPointerLock(): void;
2582
+ function requestPointerLock(unadjustedMovement): void;
2393
2583
 
2394
2584
  /** 🖲️
2395
- * Exits pointer lock, showing the cursor again and stopping the unlimited movement.
2585
+ * Exits pointer lock, showing the cursor again and stopping
2586
+ * the unlimited movement.
2396
2587
  */
2397
2588
  function exitPointerLock(): void;
2398
2589