mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 10:08:34 +00:00
A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
| .github/workflows | ||
| .vscode | ||
| __tests__ | ||
| assets | ||
| docs | ||
| examples | ||
| packages | ||
| scripts | ||
| .eslintrc.js | ||
| .gitignore | ||
| .npmrc | ||
| .prettierrc.json | ||
| babel.config.js | ||
| dev.md | ||
| jest.config.js | ||
| jest.cover.js | ||
| jest.e2e.config.js | ||
| LICENSE | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| README.md | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| tsconfig.web.json | ||
iDraw.js
iDraw.js is a simple JavaScript framework for Drawing on the web.
一个面向Web绘图的JavaScript框架
@idraw/studio Preview
The preview of @idraw/studo. Click here to get it.
Sponsors
iDraw.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome backers. If you'd like to join them, please consider sponsoring iDrawjs's development.
Install
npm i idraw
Getting Started
Common
import { iDraw } from 'idraw';
const idraw = new iDraw(
document.querySelector('#app'),
{
width: 600,
height: 400,
devicePixelRatio: 1,
}
);
idraw.addElement({
name: "rect-1",
x: 140,
y: 120,
w: 200,
h: 100,
type: "rect",
detail: {
background: "#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,
devicePixelRatio: 1,
});
idraw.addElement({
name: "rect-001",
x: 140,
y: 120,
w: 200,
h: 100,
type: "rect",
detail: {
background: "#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,
devicePixelRatio: 1,
});
idraw.addElement({
name: "rect-001",
x: 140,
y: 120,
w: 200,
h: 100,
type: "rect",
detail: {
background: "#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.gitcd idrawpnpm inpm run dev
Step 2: Development
npm run devto select and develop single package