Skip to content

Quick Start

The First Example

It is a simple example of iDraw.js that drawing a rotating rectangle.

Install NPM Module

sh
npm install idraw

Mounted DOM

html
<div id="app"></div>

Use iDraw.js

js
import { iDraw } from 'idraw';
const data = {
  elements: [
    {
      name: 'rect-001',
      x: 160,
      y: 120,
      w: 200,
      h: 100,
      angle: 30,
      type: 'rect',
      detail: {
        background: '#d5f5f9',
        borderRadius: 10,
        borderWidth: 2,
        borderColor: '#3f51b5'
      }
    }
  ]
};

const app = document.querySelector('#app');
const idraw = new iDraw(app, {
  width: 600,
  height: 400,
  devicePixelRatio: 2
});

// Setting data
idraw.setData(data);

Now, we can start the tutorials for using iDraw.js. O(∩_∩)O~