0.5.3 • Published 1 year ago

am-canvas-anno v0.5.3

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

canvas-anno

Installation

Using npm:

  npm install am-canvas-anno

Using

<div id='cannvas_anno'/>
<script>
  // 初始化
  const element = document.getElementById('cannvas_anno')
  const anno = new AnnoCanvas()
  anno.init(element,'../example/demo1.jpg')
  anno.config({
    color:'#00FF00',
    lineWidth: 2,
    max:4,
    paddingX:0,
    paddingY:0,
    paddingBackground:'rgba(0,0,0,.1)',
    fill:'rgba(255, 255, 255, 0.6)',
    selectedFill:'rgba(255, 255, 255, 0.8)',
    boxShadow:'2 2 1 rgba(0,0,0,.7)',
    // 变化触发
    onChange:(e) => {
      // console.log(e)
    },
    // 选中触发
    onSelect:(index,tag) => {
      console.log('选中触发',index,tag)
    },
    //取消选中触发
    deSelect:(index,tag) => {
      console.log('取消选中触发',index,tag)
    },
    // 背景加载/切换完成触发
    loaded:(e) => {
      console.log('背景图片加载完成')
      anno.draw({
        dot_line: [{
          path: [{x: 10, y: 10}, {x: 400, y: 100}, {x: 400, y: 400}, {x: 100, y: 400}],
          close:true,
          editAble:false,
          describtion:{
            text:'1',
            color:'#000',
            fontSize:16
          }
        }],
      })
    },
    // 单次绘画完成触发
    finished:(e) => {
      console.log(e)
    },

  })

  创建绘画
  anno.createTarget({
      type:'dot_line',
      options:{
        close:true,
        describtion:{
          text:'2',
          color:'#000',
          fontSize:14
        }
      }
    })
</script>

Config

参数说明类型默认值可选值
paintBrush绘画标记类型String'''line' 'circle' 'closed_line' 'dot_line' 'rect' 'straight_line'
color绘画默认颜色String'#f81d22'-
selectedColor选中默认颜色String'#008dff'-
lineDash虚线String""如:"5,25"
lineWidth绘画线条宽度Number2-
fill填充颜色String--
selectedFill选中填充颜色String--
dotLineLimit点线默认点数Number4-
hammerAble是否可拖拽Booleanfalse-

描述

describtion:{
            text:'1',
            color:'#000',
            fontSize:16
          }

Methods

参数说明返回默认值可选值
config设置配置---
getData获取数据tag 坐标--
clearData清除数据与画板---
onSelect选中触发---
cancel取消绘画---

resizeConfig

参数说明返回默认值可选值
fillStyle填充颜色---
strokeStyle边框颜色tag 坐标--
strokeWidth边框宽度---
width点大小---
accuracy最小点位距离---
0.5.3

1 year ago

0.5.2

1 year ago