q5 2.10.3 → 2.10.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q5",
3
- "version": "2.10.3",
3
+ "version": "2.10.6",
4
4
  "description": "A sequel to p5.js that's optimized for interactive art",
5
5
  "author": "quinton-ashley",
6
6
  "contributors": [
@@ -11,7 +11,7 @@
11
11
  "homepage": "https://q5js.org/home",
12
12
  "main": "q5-server.js",
13
13
  "scripts": {
14
- "bundle": "cat src/q5-core.js src/q5-canvas.js src/q5-2d-canvas.js src/q5-2d-drawing.js src/q5-2d-image.js src/q5-2d-text.js src/q5-ai.js src/q5-color.js src/q5-display.js src/q5-input.js src/q5-math.js src/q5-sound.js src/q5-util.js src/q5-vector.js src/q5-webgpu-canvas.js src/q5-webgpu-drawing.js src/q5-webgpu-image.js src/q5-webgpu-text.js > q5.js",
14
+ "bundle": "cat src/q5-core.js src/q5-canvas.js src/q5-2d-canvas.js src/q5-2d-drawing.js src/q5-2d-image.js src/q5-2d-soft-filters.js src/q5-2d-text.js src/q5-ai.js src/q5-color.js src/q5-display.js src/q5-input.js src/q5-math.js src/q5-sound.js src/q5-util.js src/q5-vector.js src/q5-webgpu-canvas.js src/q5-webgpu-drawing.js src/q5-webgpu-image.js src/q5-webgpu-text.js > q5.js",
15
15
  "min": "terser q5.js --compress ecma=2024 --mangle > q5.min.js",
16
16
  "dist": "bun bundle && bun min",
17
17
  "dist-p5play": "bun dist && cp q5.js ../../web/p5play-web/v3/q5.js && cp q5.min.js ../../web/p5play-web/v3/q5.min.js",
package/q5.d.ts CHANGED
@@ -1254,8 +1254,21 @@ function setup() {
1254
1254
 
1255
1255
  /** 🌆
1256
1256
  * Applies a filter to the image.
1257
- * @param {string} type - type of filter
1257
+ *
1258
+ * See the documentation for q5's filter constants below for more info.
1259
+ *
1260
+ * If a CSS filter string is provided, it will be applied to the image.
1261
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/filter
1262
+ * @param {string} type - type of filter or a CSS filter string
1258
1263
  * @param {number} [value] - optional parameter, depending on filter type
1264
+ * @example
1265
+ createCanvas(200, 200);
1266
+ let logo = loadImage('/q5js_logo.webp');
1267
+
1268
+ function setup() {
1269
+ logo.filter(INVERT);
1270
+ image(logo, 0, 0, 200, 200);
1271
+ }
1259
1272
  */
1260
1273
  function filter(type: string, value?: number): void;
1261
1274
 
@@ -1441,14 +1454,14 @@ function setup() {
1441
1454
  const BOLDITALIC: 'italic bold';
1442
1455
 
1443
1456
  /** ✍️
1444
- * Align text to the center.
1457
+ * Align text to the left.
1445
1458
  */
1446
- const CENTER: 'center';
1459
+ const LEFT: 'left';
1447
1460
 
1448
1461
  /** ✍️
1449
- * Align text to the left.
1462
+ * Align text to the center.
1450
1463
  */
1451
- const LEFT: 'left';
1464
+ const CENTER: 'center';
1452
1465
 
1453
1466
  /** ✍️
1454
1467
  * Align text to the right.
@@ -1480,25 +1493,135 @@ function setup() {
1480
1493
 
1481
1494
  // 🎨 color
1482
1495
 
1496
+ /** 🎨
1497
+ * Creates a new `Color` object. This function can parse different
1498
+ * color representations depending on the current color mode.
1499
+ *
1500
+ * RGB colors have components `r`/`red`, `g`/`green`, `b`/`blue`,
1501
+ * and `a`/`alpha`.
1502
+ *
1503
+ * When only one numeric input is provided, it'll be interpreted
1504
+ * as a grayscale value. If only two numeric inputs are provided,
1505
+ * they will be used as grayscale and alpha values.
1506
+ *
1507
+ * `fill`, `stroke`, and `background` functions can accept the same
1508
+ * wide range of inputs as this function.
1509
+ * @param {string | number | Color | number[]} c0 - first color component, a CSS color string, a `Color` object (to make copy), or an array of components
1510
+ * @param {number} [c1] - second color component
1511
+ * @param {number} [c2] - third color component
1512
+ * @param {number} [c3] - fourth color component (alpha)
1513
+ * @returns {Color} a new `Color` object
1514
+ * @example
1515
+ createCanvas(200, 200);
1516
+
1517
+ let c = color(128);
1518
+
1519
+ function draw() {
1520
+ background(c);
1521
+ c.g = (c.g + 1) % 255;
1522
+ }
1523
+ */
1524
+ function color(c0: string | number | Color | number[], c1?: number, c2?: number, c3?: number): Color;
1525
+
1483
1526
  /** 🎨
1484
1527
  * Sets the color mode for the sketch. Changes the type of color object created by color functions.
1528
+ *
1529
+ * In q2d, the default color mode is RGB in legacy integer format.
1485
1530
  *
1486
- * In WebGPU, the default color mode is 'rgb' in float format.
1531
+ * In WebGPU, the default color mode is RGB in float format.
1532
+ *
1533
+ * See the documentation for q5's color constants below for more info.
1487
1534
  * @param {'rgb' | 'srgb' | 'oklch'} mode - color mode
1488
1535
  * @param {1 | 255} format - color format (1 for float, 255 for integer)
1536
+ * @example
1537
+ createCanvas(200, 200);
1538
+
1539
+ colorMode(RGB, 1);
1540
+ fill(1, 0, 0);
1541
+ rect(0, 0, 66, 200);
1542
+ fill(0, 1, 0);
1543
+ rect(66, 0, 67, 200);
1544
+ fill(0, 0, 1);
1545
+ rect(133, 0, 67, 200);
1546
+ * @example
1547
+ createCanvas(200, 200);
1548
+
1549
+ colorMode(OKLCH);
1550
+
1551
+ fill(0.25, 0.15, 0);
1552
+ rect(0, 0, 100, 200);
1553
+ fill(0.75, 0.15, 0)
1554
+ rect(100, 0, 100, 200);
1489
1555
  */
1490
1556
  function colorMode(mode: 'rgb' | 'srgb' | 'oklch', format: 1 | 255): void;
1491
1557
 
1492
1558
  /** 🎨
1493
- * Creates a new `Color` object. It can parse different
1494
- * color representations depending on the current `colorMode`.
1495
- * @param {string | number | Color | number[]} c0 - first color component, or a string representing the color, or a `Color` object, or an array of components
1496
- * @param {number} [c1] - second color component
1497
- * @param {number} [c2] - third color component
1498
- * @param {number} [c3] - fourth color component (alpha)
1499
- * @returns {Color} a new `Color` object
1559
+ * RGB colors have components `r`/`red`, `g`/`green`, `b`/`blue`,
1560
+ * and `a`/`alpha`.
1561
+ *
1562
+ * RGB is the default color mode.
1563
+ *
1564
+ * By default when a canvas is using the `display-p3` color space,
1565
+ * rgb colors are mapped to the full P3 gamut, even when they use the
1566
+ * legacy integer format.
1567
+ * @example
1568
+ createCanvas(200, 200);
1569
+
1570
+ function setup() {
1571
+ background(255, 0, 0);
1572
+ }
1500
1573
  */
1501
- function color(c0: string | number | Color | number[], c1?: number, c2?: number, c3?: number): Color;
1574
+ const RGB: 'rgb';
1575
+
1576
+ /** 🎨
1577
+ * This color mode limits the gamut of rgb colors to sRGB.
1578
+ *
1579
+ * If your display is HDR capable, take a look at the following
1580
+ * example, note that full red appears less saturated, as it would
1581
+ * on an SDR display.
1582
+ * @example
1583
+ createCanvas(200, 200);
1584
+
1585
+ colorMode(SRGB, 255);
1586
+
1587
+ function setup() {
1588
+ background(255, 0, 0);
1589
+ }
1590
+ */
1591
+ const SRGB: 'srgb';
1592
+
1593
+ /** 🎨
1594
+ * OKLCH colors have components `l`/`lightness`, `c`/`chroma`,
1595
+ * `h`/`hue`, and `a`/`alpha`.
1596
+ *
1597
+ * You may be familiar with the outdated HSL/HSV color formats,
1598
+ * which were created in the 1970s to be more intuitive for humans
1599
+ * to work with than RGB. But due to technical limitations of that
1600
+ * time, they're not perceptually uniform, meaning colors at the same
1601
+ * brightness values may appear lighter or darker depending on the hue.
1602
+ *
1603
+ * The OKLCH format is similar to HSL/HSV but its perceptually
1604
+ * uniform and supports HDR colors. Use this oklch color picker to
1605
+ * explore the color space: https://oklch.com
1606
+ *
1607
+ * `lightness`: 0 to 1
1608
+ *
1609
+ * `chroma`: 0 to 0.3
1610
+ *
1611
+ * `hue`: 0 to 360
1612
+ *
1613
+ * `alpha`: 0 to 1
1614
+ *
1615
+ * Note how seamless the hue transitions are in the following example.
1616
+ * @example
1617
+ createCanvas(200, 200);
1618
+ colorMode(OKLCH);
1619
+
1620
+ function draw() {
1621
+ background(0.7, 0.16, frameCount % 360);
1622
+ }
1623
+ */
1624
+ const OKLCH: 'oklch';
1502
1625
 
1503
1626
  // 🖲️ input
1504
1627