Skip to content

Commit b0b40f9

Browse files
author
cahierchen
committed
Merge branch 'fastline'
2 parents 1a4801d + 3661e7d commit b0b40f9

File tree

6 files changed

+5969
-47
lines changed

6 files changed

+5969
-47
lines changed

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# canvas-select
1+
# canvas-select-pro
2+
此仓库基于 [canvas-select](https://github.com/heylight/canvas-select) 进行扩展和改进。
3+
增加了网格/标尺/单要素只读/修复了一系列 bug
4+
25

36
一个用于图片标注的 javascript 库,基于 canvas,简单轻量,支持矩形、多边形、点、折线、圆形标注、网格标注。
47

@@ -21,22 +24,14 @@
2124

2225
## 🚀 安装 (Installation)
2326

24-
您可以通过以下任一方式将 `canvas-select` 集成到您的项目中:
25-
26-
### 通过 CDN (UMD)
27-
28-
直接在 HTML 文件中引入:
29-
30-
```html
31-
<script src="https://unpkg.com/canvas-select@^2/lib/canvas-select.min.js"></script>
32-
```
27+
您可以通过以下式将 `canvas-select-pro` 集成到您的项目中:
3328

3429
### 通过 npm/yarn
3530

3631
```bash
37-
npm install canvas-select --save
32+
npm install canvas-select-pro --save
3833
# 或者
39-
yarn add canvas-select
34+
yarn add canvas-select-pro
4035
```
4136

4237
## 🛠️ 使用方法 (Usage)

index.html

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
.container {
1919
background-color: #ccc;
2020
width: 100%;
21-
max-width: 400px;
22-
height: 400px;
21+
height: 100%;
2322
}
2423

2524
.right {
@@ -61,7 +60,7 @@
6160
<script>
6261
// alert(document.body.clientWidth)
6362
const output = document.getElementById('output');
64-
const instance = new CanvasSelect('.container', 'https://n.sinaimg.cn/www/transform/300/w660h440/20240318/3875-37fb8533570d8661d3f547c7e3b0ddde.jpg');
63+
const instance = new CanvasSelect('.container', 'http://mapugcnew-1306570047.cos.ap-beijing-cdz-tmap-1.tencentcos.cn/device-image-t3/rRV5vy16p0LZxZhcBqPOtXKI_iBXywEVxoC6vdSKDuQ=/2503171414381527205/1742191492608.jpg?sign=8sMmE1Vlr8w2EzGyJu0%2BbKZ3aYVhPTEzMDY1NzAwNDcmYj1tYXB1Z2NuZXcmaz1BS0lEa1IwUGV2NDZBQkVNUWN4UG5JbTdIVWQwRVlxS3ZQakYmZT0xNzUzOTU0NzUzJnQ9MTc1Mzg2ODM1MyZyPTA0NzMwNjc5MDMmZj0%3D', { enabled: true, size: 40 });
6564
// instance.readonly = true
6665
// instance.focusMode = true
6766
instance.ctrlRadius = navigator.userAgent.includes('Mobile') ? 6 : 3
@@ -128,16 +127,14 @@
128127
instance.on('select', (info) => {
129128
console.log('当前选中1', info)
130129
});
131-
instance.on('updated', (result) => {
132-
console.log('标注结果', result)
133-
// const list = [...result]
134-
// list.sort((a, b) => a.index - b.index)
135-
// output.value = JSON.stringify(list, null, 2);
136-
});
137130
instance.on('contextmenu', () => {
138131
console.log('右键')
139132
});
140133

134+
instance.on('updateShape', (shape) => {
135+
console.log('被更新的要素:', shape);
136+
});
137+
141138
function change(num) {
142139
instance.createType = num;
143140
}
@@ -171,4 +168,4 @@
171168
</script> -->
172169
</body>
173170

174-
</html>
171+
</html>

0 commit comments

Comments
 (0)