A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
Find a file
2023-11-19 14:25:41 +08:00
.github/workflows ci: add npm provenance and upgrade version 2023-10-15 13:45:14 +08:00
.vscode feat: add header of idraw design 2023-05-27 11:23:27 +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 feat: add middleware ruler 2023-11-19 14:25:41 +08:00
scripts chore: fix upgrade version script 2023-11-04 22:48:42 +08:00
.eslintrc.js feat: init deep selector middleware 2023-06-10 18:09:11 +08:00
.gitignore build: add output esm/* to @idraw/util 2022-02-27 15:56:32 +08:00
.npmrc chore: update npmrc 2023-11-04 22:52:58 +08:00
.prettierrc.json refactor: refactor uitl for v0.4 2023-04-15 12:06:48 +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: update jest config 2023-09-16 17:32:31 +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
LICENSE doc: update LICENSE 2023-02-25 13:49:19 +08:00
package.json chore: upgrade deps 2023-11-18 10:41:19 +08:00
pnpm-lock.yaml chore: upgrade deps 2023-11-18 10:41:19 +08:00
pnpm-workspace.yaml feat: add studio to project 2023-05-20 10:08:25 +08:00
README.md doc: update readme 2023-05-06 22:21:00 +08:00
tsconfig.json chore: improve build script 2023-02-12 11:39:24 +08:00
tsconfig.node.json deps: upgrade pkg 2023-09-16 21:22:28 +08:00
tsconfig.web.json refactor: refactor drawing svg 2023-05-06 08:28:15 +08:00

iDraw.js

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

一个面向Web绘图的JavaScript框架

idraw.js.org

CI Version License


Note: At present, the development content of the main branch is v0.4, and it is currently in the development and reconstruction stage, mainly based on the v0.3 version for optimization and reconstruction. The npm module is version v0.3. If you encounter any problems while using the npm module, you can view the content of this branch: https://github.com/idrawjs/idraw/tree/v0.3

注意: 当前main分支开发内容为v0.4,目前处于开发重构阶段,主要基于v0.3版本进行优化重构。 目前npm 模块是v0.3 版本。 如果你在使用npm模块的过程中遇到什么问题可以查看这个分支的内容 https://github.com/idrawjs/idraw/tree/v0.3

@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