A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
Find a file
2022-02-27 17:06:36 +08:00
.github/workflows chore: update github actions 2021-11-26 21:23:59 +08:00
__tests__ refactor: refactor offset of controller 2021-12-11 10:57:10 +08:00
assets/preview docs: update readme 2021-08-30 17:13:08 +08:00
docs Revert "Revert "docs: update docs"" 2021-08-16 12:47:32 +08:00
packages refactor: refactor @idraw/renderer export 2022-02-27 17:06:36 +08:00
scripts refactor: refactor @idraw/renderer export 2022-02-27 17:06:36 +08:00
.eslintrc.js fix: idraw options transfer to core 2021-07-23 12:47:58 +08:00
.gitignore build: add output esm/* to @idraw/util 2022-02-27 15:56:32 +08:00
api-extractor.json feat: init project 2021-05-23 20:16:15 +08:00
babel.config.js feat: init project 2021-05-23 20:16:15 +08:00
dev.md chore: update testing script 2021-06-10 12:02:08 +08:00
jest.config.js refactor: refactor build script and @idraw/util export 2022-02-27 15:35:23 +08:00
jest.cover.js chore: update workflows/coverage.yml 2021-09-20 21:18:23 +08:00
lerna.json v0.2.0-alpha.26 2022-02-14 23:22:40 +08:00
LICENSE Initial commit 2021-05-23 19:46:41 +08:00
package.json build: add output esm/* to @idraw/util 2022-02-27 15:56:32 +08:00
README.md fix: add try-catch to warn cross domain 2022-01-05 22:50:35 +08:00
tsconfig.json build: update scripts 2022-01-03 22:51:25 +08:00

iDraw.js

iDraw.js is a simple JavaScript framework for Drawing on the web.

一个面向Web绘图的JavaScript框架

idraw.js.org

CI Version License


@idraw/studio Preview

The preview of @idraw/studo. Click here to get it.

Install

npm i idraw

Getting Started

Common

import iDraw from 'idraw';

const idraw = new iDraw(
  document.querySelector('#app'),
  {
    width: 600,
    height: 400,
    contextWidth: 600,
    contextHeight: 400,
    devicePixelRatio: 1,
  }
);
idraw.addElement({
  name: "rect-1",
  x: 140,
  y: 120,
  w: 200,
  h: 100,
  type: "rect",
  desc: {
    bgColor: "#f7d3c1",
    borderRadius: 20,
    borderWidth: 4,
    borderColor: "#ff6032",
  },
});

React

import iDraw from 'idraw';
import { useEffect, useRef } from 'react';

function Demo() {
  const ref = useRef(null);
  useEffect(() => {
    const idraw = new iDraw(ref.current, {
      width: 600,
      height: 400,
      contextWidth: 600,
      contextHeight: 400,
      devicePixelRatio: 1,
    });
    idraw.addElement({
      name: "rect-001",
      x: 140,
      y: 120,
      w: 200,
      h: 100,
      type: "rect",
      desc: {
        bgColor: "#f7d3c1",
        borderRadius: 20,
        borderWidth: 4,
        borderColor: "#ff6032",
      },
    })
  }, []);

  return (
    <div ref={ref}></div>
  )
}

Vue

<template>
  <div ref="mount"></div>
</template>

<script setup >
import iDraw from 'idraw';
import { ref, onMounted } from 'vue'
const mount = ref();

onMounted(() => {
  const idraw = new iDraw(mount.value, {
    width: 600,
    height: 400,
    contextWidth: 600,
    contextHeight: 400,
    devicePixelRatio: 1,
  });
  idraw.addElement({
    name: "rect-001",
    x: 140,
    y: 120,
    w: 200,
    h: 100,
    type: "rect",
    desc: {
      bgColor: "#f7d3c1",
      borderRadius: 20,
      borderWidth: 4,
      borderColor: "#ff6032",
    },
  })
})
</script>

Contributing

We appreciate your help!

To contribute, please follow the steps:

Step 1: Prepare Project

  • git clone git@github.com:idrawjs/idraw.git
  • cd idraw
  • npm i
  • npm run init

Step 2: Development

Simple Mode

  • npm run start to select and develop single package

Complete Mode