Skip to content

Commit

Permalink
docs: fix some issues in the README (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranet committed Sep 26, 2022
1 parent 34a75da commit 505658d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ How to use it:

```js
const { Canvas } = require('canvas-constructor/napi-rs');
// or `canvas-constructor/skia` if you are using `skia-canvas`
// or `canvas-constructor/cairo` if you are using `canvas`

new Canvas(300, 300)
Expand All @@ -61,6 +62,8 @@ new Canvas(300, 300)
</script>
```

Alternatively, you can import `canvas-constructor/browser`.

- That will create a canvas with size of 300 pixels width, 300 pixels height.
- Set the color to #AEFD54
- Draw a rectangle with the previous color, covering all the pixels from (5, 5) to (290 + 5, 290 + 5)
Expand All @@ -72,11 +75,10 @@ new Canvas(300, 300)
Now, let's suppose we want to add images, we'll use `Canvas.loadImage`, which works in both Node.js and browser:

```js
const { readFile } = require('node:fs');
const { Canvas, loadImage } = require('canvas-constructor/napi-rs');

async function createCanvas() {
const image = loadImage(await readFile('./images/kitten.png'));
const image = await loadImage('./images/kitten.png');

return new Canvas(300, 400)
.printImage(image, 0, 0, 300, 400)
Expand Down

0 comments on commit 505658d

Please sign in to comment.