q5 3.7.5 → 3.7.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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q5/q5",
3
- "version": "3.7.5",
3
+ "version": "3.7.6",
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": "3.7.5",
3
+ "version": "3.7.6",
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
@@ -729,9 +729,6 @@ declare global {
729
729
  *
730
730
  * If no fonts are loaded, the default sans-serif font is used.
731
731
  *
732
- * In q5 WebGPU, fonts in [MSDF format](https://github.com/q5js/q5.js/wiki/q5-WebGPU-renderer#text-rendering)
733
- * with the file ending "-msdf.json" can be used for high performance text rendering. Make your own using the [MSDF font converter](https://msdf-bmfont.donmccurdy.com/).
734
- *
735
732
  * By default, assets are loaded in parallel before q5 runs `draw`. Use `await` to wait for a font to load.
736
733
  * @param {string} url URL of the font to load
737
734
  * @returns {FontFace & PromiseLike<FontFace>} font
@@ -1392,14 +1389,14 @@ declare global {
1392
1389
  * Creates a new `Color` object, which is primarily useful for storing
1393
1390
  * a color that your sketch will reuse or modify later.
1394
1391
  *
1395
- * With the default RGB color mode, colors have `r`/`red`, `g`/`green`, `b`/`blue`, and `a`/`alpha` components. The default color
1396
- * format is integer, so set components to values between 0 and 255.
1397
- *
1398
- * In q5 WebGPU, the default color mode is RGB in float format, so
1399
- * set color components to values between 0 and 1.
1392
+ * With the default color mode, RGB, colors have `r`/`red`, `g`/`green`,
1393
+ * `b`/`blue`, and `a`/`alpha` components.
1400
1394
  *
1401
- * The [`fill`](https://q5js.org/learn/#fill), [`stroke`](https://q5js.org/learn/#stroke), and [`background`](https://q5js.org/learn/#background) functions
1402
- * accept the same wide range of color representations as this function.
1395
+ * The [`fill`](https://q5js.org/learn/#fill), [`stroke`](https://q5js.org/learn/#stroke), and [`background`](https://q5js.org/learn/#background)
1396
+ * functions accept the same wide range of color representations as this function.
1397
+ *
1398
+ * The default color format is "integer",
1399
+ * so set components to values between 0 and 255.
1403
1400
  *
1404
1401
  * Here are some examples of valid use:
1405
1402
  *
@@ -1452,11 +1449,9 @@ declare global {
1452
1449
  * Sets the color mode for the sketch, which changes how colors are
1453
1450
  * interpreted and displayed.
1454
1451
  *
1455
- * The default color mode is RGB in legacy integer format.
1456
- *
1457
- * In WebGPU, the default is RGB in float format (best performance).
1458
- *
1459
1452
  * Color gamut is 'display-p3' by default, if the device supports HDR.
1453
+ *
1454
+ * The default color mode is RGB in legacy integer format.
1460
1455
  * @param {'rgb' | 'oklch' | 'hsl' | 'hsb'} mode color mode
1461
1456
  * @param {1 | 255} format color format (1 for float, 255 for integer)
1462
1457
  * @param {'srgb' | 'display-p3'} [gamut] color gamut
@@ -1983,13 +1978,6 @@ declare global {
1983
1978
  *
1984
1979
  * #### webgpu
1985
1980
  * @example
1986
- * await createCanvas(200, { alpha: true });
1987
- *
1988
- * q5.draw = function () {
1989
- * clear();
1990
- * circle((frameCount % 200) - 100, 0, 80);
1991
- * };
1992
- * @example
1993
1981
  * createCanvas(200, 200, { alpha: true });
1994
1982
  *
1995
1983
  * function draw() {
@@ -2099,11 +2087,7 @@ declare global {
2099
2087
  /** 🦋
2100
2088
  * Applies a transformation matrix.
2101
2089
  *
2102
- * Accepts a 3x3 or 4x4 matrix as either an array or multiple arguments.
2103
- *
2104
- * Note that in q5 WebGPU, the identity matrix (default)
2105
- * has a negative y scale to flip the y-axis to match
2106
- * the Canvas2D renderer.
2090
+ * Accepts a 3x3 matrix as either an array or multiple arguments.
2107
2091
  * @param {number} a
2108
2092
  * @param {number} b
2109
2093
  * @param {number} c
package/q5.js CHANGED
@@ -280,7 +280,7 @@ function Q5(scope, parent, renderer) {
280
280
  for (let name of userFns) $[name] ??= () => {};
281
281
 
282
282
  if ($._isGlobal) {
283
- let allUserFns = Q5._userFns.slice(0, 17);
283
+ let allUserFns = Q5._userFns.slice(0, 19);
284
284
 
285
285
  for (let name of allUserFns) {
286
286
  if (Q5[name]) $[name] = Q5[name];
@@ -399,6 +399,8 @@ Q5._userFns = [
399
399
  'touchMoved',
400
400
  'touchEnded',
401
401
  'windowResized',
402
+ 'preload',
403
+ 'setup',
402
404
  'update',
403
405
  'draw'
404
406
  ];
@@ -8468,30 +8470,296 @@ Q5.WebGPU = async function (scope, parent) {
8468
8470
  const libLangs = `
8469
8471
  # core
8470
8472
  createCanvas -> es:crearLienzo ja:キャンバスを作成する
8473
+ log -> es:log
8471
8474
 
8472
8475
  # color
8473
8476
  background -> es:fondo ja:背景
8477
+ fill -> es:relleno
8478
+ stroke -> es:trazo
8479
+ noFill -> es:sinRelleno
8480
+ noStroke -> es:sinTrazo
8481
+ color -> es:color
8482
+ colorMode -> es:modoColor
8474
8483
 
8475
8484
  # display
8476
8485
  windowWidth -> es:anchoVentana
8477
8486
  windowHeight -> es:altoVentana
8487
+ width -> es:ancho
8488
+ height -> es:alto
8478
8489
  frameCount -> es:cuadroActual
8479
8490
  noLoop -> es:pausar
8480
8491
  redraw -> es:redibujar
8481
8492
  loop -> es:reanudar
8482
8493
  frameRate -> es:frecuenciaRefresco
8483
- getTargetFrameRate -> es:frecuenciaIdeal
8484
- getFPS -> es:frecuenciaMaxima
8485
- deltaTime -> es:ultimoTiempo
8494
+ getTargetFrameRate -> es:obtenerTasaFotogramasObjetivo
8495
+ getFPS -> es:obtenerFPS
8496
+ deltaTime -> es:deltaTiempo
8497
+ pixelDensity -> es:densidadPíxeles
8498
+ displayDensity -> es:densidadVisualización
8499
+ fullscreen -> es:pantallaCompleta
8500
+ displayMode -> es:modoVisualización
8501
+ halfWidth -> es:medioAncho
8502
+ halfHeight -> es:medioAlto
8503
+ canvas -> es:lienzo
8504
+ resizeCanvas -> es:redimensionarLienzo
8505
+ drawingContext -> es:contextoDibujo
8486
8506
 
8487
8507
  # shape
8488
8508
  circle -> es:círculo
8509
+ ellipse -> es:elipse
8510
+ rect -> es:rect
8511
+ square -> es:cuadrado
8512
+ point -> es:punto
8513
+ line -> es:línea
8514
+ capsule -> es:cápsula
8515
+ rectMode -> es:modoRect
8516
+ ellipseMode -> es:modoEliptico
8517
+ arc -> es:arco
8518
+ curve -> es:curva
8519
+ beginShape -> es:empezarForma
8520
+ endShape -> es:terminarForma
8521
+ vertex -> es:vértice
8522
+ bezier -> es:bezier
8523
+ triangle -> es:triángulo
8524
+ quad -> es:quad
8525
+ curveDetail -> es:detalleCurva
8526
+ beginContour -> es:empezarContorno
8527
+ endContour -> es:terminarContorno
8528
+ bezierVertex -> es:vérticeBezier
8529
+ quadraticVertex -> es:vérticeCuadrático
8530
+
8531
+ # image
8532
+ loadImage -> es:cargarImagen
8533
+ image -> es:imagen
8534
+ imageMode -> es:modoImagen
8535
+ noTint -> es:noTeñir
8536
+ tint -> es:teñir
8537
+ filter -> es:filtro
8538
+ createImage -> es:crearImagen
8539
+ createGraphics -> es:crearGráficos
8540
+ defaultImageScale -> es:escalaImagenPorDefecto
8541
+ resize -> es:redimensionar
8542
+ trim -> es:recortar
8543
+ smooth -> es:suavizar
8544
+ noSmooth -> es:noSuavizar
8545
+ mask -> es:enmascarar
8546
+ copy -> es:copiar
8547
+ inset -> es:insertado
8548
+ get -> es:obtener
8549
+ set -> es:establecer
8550
+ pixels -> es:píxeles
8551
+ loadPixels -> es:cargarPíxeles
8552
+ updatePixels -> es:actualizarPíxeles
8553
+
8554
+ # text
8555
+ text -> es:texto
8556
+ loadFont -> es:cargarFuente
8557
+ textFont -> es:fuenteTexto
8558
+ textSize -> es:tamañoTexto
8559
+ textLeading -> es:interlineado
8560
+ textStyle -> es:estiloTexto
8561
+ textAlign -> es:alineaciónTexto
8562
+ textWidth -> es:anchoTexto
8563
+ textWeight -> es:pesoTexto
8564
+ textAscent -> es:ascensoTexto
8565
+ textDescent -> es:descensoTexto
8566
+ createTextImage -> es:crearImagenTexto
8567
+ textImage -> es:imagenTexto
8568
+ nf -> es:nf
8569
+
8570
+ # input
8571
+ mouseX -> es:ratónX
8572
+ mouseY -> es:ratónY
8573
+ pmouseX -> es:pRatónX
8574
+ pmouseY -> es:pRatónY
8575
+ mouseIsPressed -> es:ratónPresionado
8576
+ mouseButton -> es:botónRatón
8577
+ key -> es:tecla
8578
+ keyIsPressed -> es:teclaPresionada
8579
+ keyIsDown -> es:teclaEstaPresionada
8580
+ touches -> es:toques
8581
+ pointers -> es:punteros
8582
+ cursor -> es:cursor
8583
+ noCursor -> es:sinCursor
8584
+ pointerLock -> es:bloqueoPuntero
8585
+
8586
+ # style
8587
+ strokeWeight -> es:grosorTrazo
8588
+ opacity -> es:opacidad
8589
+ shadow -> es:sombra
8590
+ noShadow -> es:sinSombra
8591
+ shadowBox -> es:cajaSombra
8592
+ blendMode -> es:modoMezcla
8593
+ strokeCap -> es:terminaciónTrazo
8594
+ strokeJoin -> es:uniónTrazo
8595
+ erase -> es:borrar
8596
+ noErase -> es:noBorrar
8597
+ clear -> es:limpiar
8598
+ pushStyles -> es:guardarEstilos
8599
+ popStyles -> es:recuperarEstilos
8600
+ inFill -> es:enRelleno
8601
+ inStroke -> es:enTrazo
8602
+
8603
+ # transform
8604
+ translate -> es:trasladar
8605
+ rotate -> es:rotar
8606
+ scale -> es:escalar
8607
+ shearX -> es:cizallarX
8608
+ shearY -> es:cizallarY
8609
+ applyMatrix -> es:aplicarMatriz
8610
+ resetMatrix -> es:reiniciarMatriz
8611
+ push -> es:guardar
8612
+ pop -> es:recuperar
8613
+ pushMatrix -> es:guardarMatriz
8614
+ popMatrix -> es:recuperarMatriz
8615
+
8616
+ # math
8617
+ random -> es:aleatorio
8618
+ noise -> es:ruido
8619
+ dist -> es:dist
8620
+ map -> es:mapa
8621
+ angleMode -> es:modoÁngulo
8622
+ radians -> es:radianes
8623
+ degrees -> es:grados
8624
+ lerp -> es:interpolar
8625
+ constrain -> es:constreñir
8626
+ norm -> es:norm
8627
+ abs -> es:abs
8628
+ round -> es:redondear
8629
+ ceil -> es:techo
8630
+ floor -> es:piso
8631
+ min -> es:min
8632
+ max -> es:max
8633
+ pow -> es:pot
8634
+ sq -> es:cuad
8635
+ sqrt -> es:raiz
8636
+ exp -> es:exp
8637
+ randomSeed -> es:semillaAleatoria
8638
+ randomGaussian -> es:aleatorioGaussiano
8639
+ noiseMode -> es:modoRuido
8640
+ noiseSeed -> es:semillaRuido
8641
+ noiseDetail -> es:detalleRuido
8642
+ jit -> es:flu
8643
+ randomGenerator -> es:generadorAleatorio
8644
+ randomExponential -> es:aleatorioExponencial
8645
+
8646
+ # sound
8647
+ loadSound -> es:cargarSonido
8648
+ loadAudio -> es:cargarAudio
8649
+ getAudioContext -> es:obtenerContextoAudio
8650
+ userStartAudio -> es:iniciarAudioUsuario
8651
+
8652
+ # dom
8653
+ createElement -> es:crearElemento
8654
+ createA -> es:crearA
8655
+ createButton -> es:crearBotón
8656
+ createCheckbox -> es:crearCasilla
8657
+ createColorPicker -> es:crearSelectorColor
8658
+ createImg -> es:crearImg
8659
+ createInput -> es:crearEntrada
8660
+ createP -> es:crearP
8661
+ createRadio -> es:crearOpciónes
8662
+ createSelect -> es:crearSelección
8663
+ createSlider -> es:crearDeslizador
8664
+ createVideo -> es:crearVideo
8665
+ createCapture -> es:crearCaptura
8666
+ findElement -> es:encontrarElemento
8667
+ findElements -> es:encontrarElementos
8668
+
8669
+ # record
8670
+ createRecorder -> es:crearGrabadora
8671
+ record -> es:grabar
8672
+ pauseRecording -> es:pausarGrabación
8673
+ deleteRecording -> es:borrarGrabación
8674
+ saveRecording -> es:guardarGrabación
8675
+ recording -> es:grabando
8676
+
8677
+ # io
8678
+ load -> es:cargar
8679
+ save -> es:guardar
8680
+ loadJSON -> es:cargarJSON
8681
+ loadStrings -> es:cargarTexto
8682
+ year -> es:año
8683
+ day -> es:día
8684
+ hour -> es:hora
8685
+ minute -> es:minuto
8686
+ second -> es:segundo
8687
+ loadCSV -> es:cargarCSV
8688
+ loadXML -> es:cargarXML
8689
+ loadAll -> es:cargarTodo
8690
+ disablePreload -> es:deshabilitarPrecarga
8691
+ shuffle -> es:barajar
8692
+ storeItem -> es:guardarItem
8693
+ getItem -> es:obtenerItem
8694
+ removeItem -> es:eliminarItem
8695
+ clearStorage -> es:limpiarAlmacenamiento
8696
+
8697
+ # shaders
8698
+ createShader -> es:crearShader
8699
+ plane -> es:plano
8700
+ shader -> es:shader
8701
+ resetShader -> es:reiniciarShader
8702
+ resetFrameShader -> es:reiniciarShaderFotograma
8703
+ resetImageShader -> es:reiniciarShaderImagen
8704
+ resetVideoShader -> es:reiniciarShaderVideo
8705
+ resetTextShader -> es:reiniciarShaderTexto
8706
+ resetShaders -> es:reiniciarShaders
8707
+ createFrameShader -> es:crearShaderFotograma
8708
+ createImageShader -> es:crearShaderImagen
8709
+ createVideoShader -> es:crearShaderVideo
8710
+ createTextShader -> es:crearShaderTexto
8711
+
8712
+ # constants
8713
+ CORNER -> es:ESQUINA
8714
+ RADIUS -> es:RADIO
8715
+ CORNERS -> es:ESQUINAS
8716
+ THRESHOLD -> es:UMBRAL
8717
+ GRAY -> es:GRIS
8718
+ OPAQUE -> es:OPACO
8719
+ INVERT -> es:INVERTIR
8720
+ POSTERIZE -> es:POSTERIZAR
8721
+ DILATE -> es:DILATAR
8722
+ ERODE -> es:EROSIONAR
8723
+ BLUR -> es:DESENFOCAR
8724
+ NORMAL -> es:NORMAL
8725
+ ITALIC -> es:CURSIVA
8726
+ BOLD -> es:NEGRILLA
8727
+ BOLDITALIC -> es:NEGRILLA_CURSIVA
8728
+ LEFT -> es:IZQUIERDA
8729
+ CENTER -> es:CENTRO
8730
+ RIGHT -> es:DERECHA
8731
+ TOP -> es:ARRIBA
8732
+ BOTTOM -> es:ABAJO
8733
+ BASELINE -> es:LINEA_BASE
8734
+ RGB -> es:RGB
8735
+ OKLCH -> es:OKLCH
8736
+ HSL -> es:HSL
8737
+ HSB -> es:HSB
8738
+ SRGB -> es:SRGB
8739
+ DISPLAY_P3 -> es:DISPLAY_P3
8740
+ MAXED -> es:MAXIMIZADO
8741
+ SMOOTH -> es:SUAVE
8742
+ PIXELATED -> es:PIXELADO
8743
+ TWO_PI -> es:DOS_PI
8744
+ HALF_PI -> es:MEDIO_PI
8745
+ QUARTER_PI -> es:CUARTO_PI
8489
8746
  `;
8490
8747
 
8491
8748
  const userLangs = `
8492
8749
  update -> es:actualizar
8493
8750
  draw -> es:dibujar
8494
- postProcess -> es:retocarDibujo
8751
+ postProcess -> es:postProcesar
8752
+ mousePressed -> es:alPresionarRatón
8753
+ mouseReleased -> es:alSoltarRatón
8754
+ mouseMoved -> es:alMoverRatón
8755
+ mouseDragged -> es:alArrastrarRatón
8756
+ doubleClicked -> es:dobleClic
8757
+ keyPressed -> es:alPresionarTecla
8758
+ keyReleased -> es:alSoltarTecla
8759
+ touchStarted -> es:alEmpezarToque
8760
+ touchEnded -> es:alTerminarToque
8761
+ touchMoved -> es:alMoverToque
8762
+ mouseWheel -> es:ruedaRatón
8495
8763
  `;
8496
8764
 
8497
8765
  const parseLangs = function (data, lang) {
@@ -8562,11 +8830,22 @@ Q5.modules.lang = ($) => {
8562
8830
  }
8563
8831
  };
8564
8832
 
8565
- Q5.addHook('presetup', ($) => {
8833
+ Q5.addHook('init', (q) => {
8566
8834
  let libMap = Q5._libMap;
8567
8835
 
8568
8836
  for (let name in libMap) {
8569
8837
  let translatedName = libMap[name];
8570
- $[translatedName] = $[name];
8838
+ q[translatedName] = q[name];
8839
+ }
8840
+ });
8841
+
8842
+ Q5.addHook('predraw', (q) => {
8843
+ let libMap = Q5._libMap;
8844
+
8845
+ // update mouse
8846
+ if (libMap.mouseX) {
8847
+ q[libMap.mouseX] = q.mouseX;
8848
+ q[libMap.mouseY] = q.mouseY;
8849
+ q[libMap.mouseIsPressed] = q.mouseIsPressed;
8571
8850
  }
8572
8851
  });