@gjsify/canvas2d-core 0.4.42 → 0.4.44
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 +39 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @gjsify/canvas2d-core
|
|
2
|
+
|
|
3
|
+
Headless `CanvasRenderingContext2D` implementation backed by Cairo and PangoCairo, with no GTK dependency. Provides `CanvasRenderingContext2D`, `CanvasGradient`, `CanvasPattern`, `Path2D`, `ImageData`, and a color parser — usable in worker-like contexts. This is the portable core extracted from `@gjsify/canvas2d`; it is auto-registered as the `'2d'` context factory when `@gjsify/dom-elements` is imported.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gjsify install @gjsify/canvas2d-core
|
|
11
|
+
|
|
12
|
+
# npm or yarn also work (e.g. adding it to an existing project):
|
|
13
|
+
npm install @gjsify/canvas2d-core
|
|
14
|
+
yarn add @gjsify/canvas2d-core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { CanvasRenderingContext2D, ImageData } from '@gjsify/canvas2d-core';
|
|
21
|
+
|
|
22
|
+
// Create a 200×200 offscreen context backed by a Cairo ImageSurface
|
|
23
|
+
const ctx = new CanvasRenderingContext2D(200, 200);
|
|
24
|
+
|
|
25
|
+
ctx.fillStyle = '#3584e4';
|
|
26
|
+
ctx.fillRect(10, 10, 180, 180);
|
|
27
|
+
|
|
28
|
+
ctx.strokeStyle = '#ffffff';
|
|
29
|
+
ctx.lineWidth = 4;
|
|
30
|
+
ctx.strokeRect(20, 20, 160, 160);
|
|
31
|
+
|
|
32
|
+
// Read pixel data
|
|
33
|
+
const imageData = ctx.getImageData(0, 0, 200, 200);
|
|
34
|
+
console.log(imageData.width, imageData.height); // 200 200
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/canvas2d-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.44",
|
|
4
4
|
"description": "Cairo-backed Canvas 2D core (CanvasRenderingContext2D, Path2D, ImageData) — no GTK dependency",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@girs/pangocairo-1.0": "1.0.0-4.0.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@gjsify/cli": "^0.4.
|
|
52
|
-
"@gjsify/dom-elements": "^0.4.
|
|
53
|
-
"@gjsify/unit": "^0.4.
|
|
51
|
+
"@gjsify/cli": "^0.4.44",
|
|
52
|
+
"@gjsify/dom-elements": "^0.4.44",
|
|
53
|
+
"@gjsify/unit": "^0.4.44",
|
|
54
54
|
"@types/node": "^25.9.1",
|
|
55
55
|
"typescript": "^6.0.3"
|
|
56
56
|
},
|