mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 01:58:27 +00:00
docs: update readme for @idraw/renderer
This commit is contained in:
parent
e639e39244
commit
38fc481208
1 changed files with 66 additions and 1 deletions
|
|
@ -1,3 +1,68 @@
|
|||
# @idraw/renderer
|
||||
|
||||
[](https://github.com/idrawjs/idraw/actions/workflows/node.js.yml)
|
||||
[](https://github.com/idrawjs/idraw/actions/workflows/node.js.yml)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### Quick Start
|
||||
|
||||
```sh
|
||||
npm i @idraw/renderer
|
||||
```
|
||||
|
||||
```js
|
||||
import Renderer from '@idraw/renderer';
|
||||
|
||||
const renderer = new Renderer({
|
||||
width: 600,
|
||||
height: 400,
|
||||
contextWidth: 600,
|
||||
contextHeight: 400,
|
||||
devicePixelRatio: 1,
|
||||
});
|
||||
|
||||
const canvas = document.querySelector('canvas');
|
||||
renderer.render(canvas, {
|
||||
elements: [
|
||||
{
|
||||
name: "rect-001",
|
||||
x: 10,
|
||||
y: 10,
|
||||
w: 200,
|
||||
h: 100,
|
||||
type: "rect",
|
||||
desc: {
|
||||
bgColor: "#f0f0f0",
|
||||
borderRadius: 20,
|
||||
borderWidth: 10,
|
||||
borderColor: "#bd0b64",
|
||||
},
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
### Events
|
||||
|
||||
```js
|
||||
renderer.on('load', (e) => {
|
||||
// ...
|
||||
})
|
||||
renderer.on('loadComplete', (e) => {
|
||||
// ...
|
||||
})
|
||||
|
||||
renderer.on('drawFrame', (e) => {
|
||||
// ...
|
||||
})
|
||||
renderer.on('drawFrameComplete', (e) => {
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
## Documents
|
||||
|
||||
- [Documents](https://idraw.js.org/docs/en/) | [中文文档](https://idraw.js.org/docs/zh/)
|
||||
- [Online Playground](https://idraw.js.org/playground/) | [在线API示例](https://idraw.js.org/playground/)
|
||||
Loading…
Reference in a new issue