npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

am-canvas-anno

v0.5.3

Published

canvas绘图标注

Readme

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 | 绘画线条宽度 | Number | 2 | - | | fill | 填充颜色 | String | - | - | | selectedFill | 选中填充颜色 | String | - | - | | dotLineLimit | 点线默认点数 | Number | 4 | - | | hammerAble | 是否可拖拽 | Boolean | false | - |

描述

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

Methods

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

resizeConfig

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