q5 2.5.3 → 2.5.5
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/README.md +31 -337
- package/package.json +1 -1
- package/q5.d.ts +81 -20
- package/q5.js +25 -14
- package/q5.min.js +1 -1
- package/src/q5-core.js +2 -1
- package/src/q5-input.js +2 -0
- package/src/q5-util.js +1 -1
- package/src/q5-webgpu-canvas.js +20 -12
- package/src/readme.md +20 -42
package/src/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# q5.js Source Documentation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
For modular use, the "q5-core.js" module must be loaded first.
|
|
4
4
|
|
|
5
5
|
```html
|
|
6
6
|
<script src="https://q5js.org/src/q5-core.js"></script>
|
|
@@ -9,6 +9,7 @@ To use q5 modules, "q5.js" (the default bundle) or the "q5-core.js" module must
|
|
|
9
9
|
These modules are included in the default "q5.js" bundle:
|
|
10
10
|
|
|
11
11
|
```html
|
|
12
|
+
<script src="https://q5js.org/src/q5-core.js"></script>
|
|
12
13
|
<script src="https://q5js.org/src/q5-2d-canvas.js"></script>
|
|
13
14
|
<script src="https://q5js.org/src/q5-2d-drawing.js"></script>
|
|
14
15
|
<script src="https://q5js.org/src/q5-2d-image.js"></script>
|
|
@@ -37,19 +38,21 @@ WebGPU rendering modules are in development:
|
|
|
37
38
|
```html
|
|
38
39
|
<script src="https://q5js.org/src/q5-webgpu-canvas.js"></script>
|
|
39
40
|
<script src="https://q5js.org/src/q5-webgpu-drawing.js"></script>
|
|
41
|
+
<script src="https://q5js.org/src/q5-webgpu-image.js"></script>
|
|
42
|
+
<script src="https://q5js.org/src/q5-webgpu-text.js"></script>
|
|
40
43
|
```
|
|
41
44
|
|
|
42
45
|
# Module Info
|
|
43
46
|
|
|
44
|
-
- [
|
|
47
|
+
- [q5.js Source Documentation](#q5js-source-documentation)
|
|
45
48
|
- [Module Info](#module-info)
|
|
46
|
-
- [core](#core)
|
|
47
|
-
- [canvas](#canvas)
|
|
49
|
+
- [q5-core](#q5-core)
|
|
50
|
+
- [q5-canvas](#q5-canvas)
|
|
48
51
|
- [q2d-canvas](#q2d-canvas)
|
|
49
|
-
- [q2d-drawing](#q2d-drawing)
|
|
50
|
-
- [q2d-image](#q2d-image)
|
|
51
|
-
- [q2d-soft-filters](#q2d-soft-filters)
|
|
52
|
-
- [q2d-text](#q2d-text)
|
|
52
|
+
- [q5-q2d-drawing](#q5-q2d-drawing)
|
|
53
|
+
- [q5-q2d-image](#q5-q2d-image)
|
|
54
|
+
- [q5-q2d-soft-filters](#q5-q2d-soft-filters)
|
|
55
|
+
- [q5-q2d-text](#q5-q2d-text)
|
|
53
56
|
- [webgpu-canvas](#webgpu-canvas)
|
|
54
57
|
- [webgpu-drawing](#webgpu-drawing)
|
|
55
58
|
- [webgpu-image](#webgpu-image)
|
|
@@ -63,15 +66,15 @@ WebGPU rendering modules are in development:
|
|
|
63
66
|
- [math](#math)
|
|
64
67
|
- [noisier](#noisier)
|
|
65
68
|
|
|
66
|
-
## core
|
|
69
|
+
## q5-core
|
|
67
70
|
|
|
68
71
|
The core module provides the absolute basic functionality necessary to run q5.
|
|
69
72
|
|
|
70
73
|
It loads other modules by passing `$` (alias for `this`) and `q` (which in global mode is a proxy for `this` and `window` or `global`).
|
|
71
74
|
|
|
72
|
-
## canvas
|
|
75
|
+
## q5-canvas
|
|
73
76
|
|
|
74
|
-
The canvas module provides shared functionality for all canvas renderers, such as adding the canvas to the DOM, resizing the canvas, setting pixel density
|
|
77
|
+
The canvas module provides shared functionality for all canvas renderers, such as adding the canvas to the DOM, resizing the canvas, setting pixel density.
|
|
75
78
|
|
|
76
79
|
## q2d-canvas
|
|
77
80
|
|
|
@@ -81,17 +84,17 @@ All other 2D modules depend on this module.
|
|
|
81
84
|
|
|
82
85
|
Though loading q5-color is recommend, it's not required since `fill` and `stroke` can be set to a CSS color string.
|
|
83
86
|
|
|
84
|
-
## q2d-drawing
|
|
87
|
+
## q5-q2d-drawing
|
|
85
88
|
|
|
86
89
|
Adds Canvas2D drawing functions to q5.
|
|
87
90
|
|
|
88
|
-
## q2d-image
|
|
91
|
+
## q5-q2d-image
|
|
89
92
|
|
|
90
93
|
Adds Canvas2D image support to q5.
|
|
91
94
|
|
|
92
95
|
The filters in q5-image use the [CanvasRenderingContext2D.filter](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter) property to apply native hardware-accelerated filters to images.
|
|
93
96
|
|
|
94
|
-
## q2d-soft-filters
|
|
97
|
+
## q5-q2d-soft-filters
|
|
95
98
|
|
|
96
99
|
Software implementation of image filters.
|
|
97
100
|
|
|
@@ -101,18 +104,12 @@ These filters are slow. Real-time use of them is not recommended.
|
|
|
101
104
|
|
|
102
105
|
As of April 2024, Safari Technology Preview supports `ctx.filter` under a flag. Hopefully in the near future this module can be omitted from the default bundle.
|
|
103
106
|
|
|
104
|
-
## q2d-text
|
|
107
|
+
## q5-q2d-text
|
|
105
108
|
|
|
106
109
|
Adds Canvas2D text rendering support to q5.
|
|
107
110
|
|
|
108
111
|
Image based features in this module require the q5-2d-image module.
|
|
109
112
|
|
|
110
|
-
`createTextImage(str, w, h)` provides a simple way for users to create images from text.
|
|
111
|
-
|
|
112
|
-
`textImage(img, x, y)` displays text images, complying with the user's text position settings instead of their image position settings. The idea is that text will appear in the same place as it would if it were drawn with the `text` function.
|
|
113
|
-
|
|
114
|
-
`textCache(bool, maxSize)` enables or disables text caching.
|
|
115
|
-
|
|
116
113
|
## webgpu-canvas
|
|
117
114
|
|
|
118
115
|
> ⚠️ Experimental features! ⚠️
|
|
@@ -138,29 +135,10 @@ WebGPU has different default settings compared to q5's q2d renderer and p5's P2D
|
|
|
138
135
|
- The default color mode is RGB in 0-1 "float" format: `colorMode(RGB, 1)`.
|
|
139
136
|
- The origin of the canvas (0, 0) is in the center, not the top left.
|
|
140
137
|
- Mouse and touch coordinates correspond to canvas pixels.
|
|
141
|
-
-
|
|
142
|
-
- For now, strokes are only implemented for the `point`, `line`, and `text` functions.
|
|
138
|
+
- For now, strokes are only implemented for the `point`, `line`, and `textImage` functions.
|
|
143
139
|
|
|
144
140
|
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.
|
|
145
141
|
|
|
146
|
-
Use of top level global mode with the WebGPU renderer requires that you make your sketch file a js module and await for `Q5.webgpu()` to return the Q5 instance (`q`), which you can then use to set q5 functions such as `draw`.
|
|
147
|
-
|
|
148
|
-
```html
|
|
149
|
-
<script type="module" src="sketch.js">
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
let q = await Q5.webgpu();
|
|
154
|
-
|
|
155
|
-
createCanvas(200, 200);
|
|
156
|
-
noStroke();
|
|
157
|
-
|
|
158
|
-
q.draw = () => {
|
|
159
|
-
clear();
|
|
160
|
-
rect(50, 50, 100, 100);
|
|
161
|
-
};
|
|
162
|
-
```
|
|
163
|
-
|
|
164
142
|
Implemented functions:
|
|
165
143
|
|
|
166
144
|
`createCanvas`, `resizeCanvas`, `fill`, `clear`, `push`, `pop`, `resetMatrix`, `translate`, `rotate`, `scale`
|