Skip to content

Commit

Permalink
2.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
quinton-ashley committed Oct 12, 2024
1 parent 69462af commit 74d7ef0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "q5",
"version": "2.6.0",
"version": "2.6.1",
"description": "A sequel to p5.js that's optimized for interactive art",
"author": "quinton-ashley",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion q5.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Q5._nodejs = typeof process == 'object';

Q5._instanceCount = 0;
Q5._friendlyError = (msg, func) => {
throw Error(func + ': ' + msg);
console.error(func + ': ' + msg);
};
Q5._validateParameters = () => true;

Expand Down
2 changes: 1 addition & 1 deletion q5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/q5-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Q5._nodejs = typeof process == 'object';

Q5._instanceCount = 0;
Q5._friendlyError = (msg, func) => {
throw Error(func + ': ' + msg);
console.error(func + ': ' + msg);
};
Q5._validateParameters = () => true;

Expand Down
26 changes: 8 additions & 18 deletions src/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ WebGPU rendering modules are in development:
- [Load a MSDF font](#load-a-msdf-font)
- [Displaying Emojis](#displaying-emojis)
- [Lightweight Use](#lightweight-use)
- [Implemented functions](#implemented-functions)
- [Limitations](#limitations)
- [math](#math)
- [noisier](#noisier)

Expand Down Expand Up @@ -114,7 +114,7 @@ Image based features in this module require the q5-2d-image module.

> ⚠️ Experimental features! ⚠️
To use q5's WebGPU renderer, run `Q5.webgpu()` at the bottom of your sketch. Explicit use of `createCanvas` is required.
To use q5's WebGPU renderer, run `Q5.webgpu()` at the bottom of your sketch.

```js
function setup() {
Expand All @@ -132,34 +132,24 @@ Q5.webgpu();

WebGPU has different default settings compared to q5's q2d renderer and p5's P2D and WEBGL modes.

- Explicit use of `createCanvas` is required before anything can be drawn.
- The default color mode is RGB in 0-1 "float" format: `colorMode(RGB, 1)`.
- The origin of the canvas (0, 0) is in the center, not the top left.
- Mouse and touch coordinates correspond to canvas pixels.
- For now, strokes are only implemented for the `point`, `line`, and `textImage` functions.
- Mouse and touch coordinates correspond to canvas pixels (unlike in p5 WEBGL mode).

The sketches you create with the q5-webgpu renderer will still display properly if WebGPU is not supported on a viewer's browser. q5 will put a warning in the console and apply a compatibility layer to display sketches with the fallback q2d renderer.

Implemented functions:

`createCanvas`, `resizeCanvas`, `fill`, `clear`, `push`, `pop`, `resetMatrix`, `translate`, `rotate`, `scale`

## webgpu-drawing

> Uses `colorMode(RGB, 1)` by default. Changing it to 'oklch' is not supported yet for the webgpu renderer.
All basic shapes are drawn from their center. Strokes are not implemented yet.

q5's WebGPU renderer drawing functions like `rect` don't immediately draw on the canvas. Instead, they prepare vertex and color data to be sent to the GPU in bulk, which occurs after the user's `draw` function and any post-draw functions are run. This approach better utilizes the GPU, so it doesn't have to repeatedly wait for the CPU to send small chunks of data that describe each individual shape. It's the main reason why WebGPU is faster than Canvas2D.

Implemented functions:

- `rect`, `circle`, `ellipse`, `triangle`, `line`, `point`, `beginShape`, `vertex`, `endShape`, `rectMode`, `ellipseMode`
Rounded rectangles, stroke modes, and functions for drawing curves like `bezier` and `curve` are not implemented yet.

## webgpu-image

Implemented functions:

`loadImage`, `loadTexture`, `image`, `imageMode`
Using `image` to drawn a subsection of an image and most blending modes are not yet implemented.

## webgpu-text

Expand Down Expand Up @@ -238,9 +228,9 @@ For super lightweight use load <https://q5js.org/fonts/YaHei-256-msdf.json>, whi
!@'",-.0123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
```

### Implemented functions
### Limitations

`loadFont`, `text`, `textFont`, `textSize`, `textAlign`, `textWidth`, `createTextImage`, `textImage`
Text strokes are not supported yet, except with `textImage`.

## math

Expand Down

0 comments on commit 74d7ef0

Please sign in to comment.