A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
Find a file
大深海 035efeb663
Merge pull request #193 from idrawjs/dev-v0.3
fix:  fix the issue of ineffective updateElement
2023-05-27 16:49:38 +08:00
.github/workflows ci: upgrade node version 2023-02-25 13:40:10 +08:00
.vscode refactor: refactor scripts 2022-12-31 23:21:57 +08:00
__tests__ test: update unit test and e2e test 2023-04-02 12:10:48 +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
examples test: improve e2e test 2023-02-12 14:01:56 +08:00
packages v0.3.1 2023-05-27 16:45:46 +08:00
scripts chore: improve ts compiler 2023-02-25 11:27:41 +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
.npmrc fix: npmrc 2023-04-02 14:42:19 +08:00
.prettierrc.json refactor: refactor scripts 2022-12-31 23:21:57 +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 test: refactor unit test 2023-02-12 13:34:06 +08:00
jest.cover.js test: improve e2e test 2023-02-12 14:44:56 +08:00
jest.e2e.config.js test: update unit test and e2e test 2023-04-02 12:10:48 +08:00
lerna.json v0.3.1 2023-05-27 16:45:46 +08:00
LICENSE doc: update LICENSE 2023-02-25 13:49:19 +08:00
package.json test: update unit test and e2e test 2023-04-02 12:10:48 +08:00
pnpm-lock.yaml chore: update pnpm-lock 2023-05-27 16:48:54 +08:00
pnpm-workspace.yaml chore: add pnpm usage 2022-12-31 17:42:21 +08:00
README.md doc: update contributing steps 2022-04-28 23:50:22 +08:00
tsconfig.json chore: improve build script 2023-02-12 11:39:24 +08:00
tsconfig.node.json test: refactor unit test 2023-02-12 13:34:06 +08:00
tsconfig.web.json chore: update tsconfig 2023-02-12 14:51:10 +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

  • npm run dev to select and develop single package