Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas-comment

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-comment

canvas-comment

  • 0.0.7
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

canvas-comment

Canvas Comment

Install

use npm

npm i canvas-comment

Usage

import CanvasComment from 'canvas-comment';

const cc = new CanvasComment({
  container: '.container',
  image: 'https://cdn-health.zhongan.com/hic/library/resource/613b041f23e187001cab3a3f/diaCLksvKr.png',
});

// When canvas loaded will trigger load event
cc.on('load', () => {

  // You can set inital data. ex.
  cc.setData([
    {
      type: 'rect',
      label: '这里不合规',
      coor: [
        [128, 687],
        [617, 722],
      ],
    },
    {
      type: 'rect',
      label: '率表有误',
      coor: [
        [381, 503],
        [669, 531],
      ],
    },
  ]);
});

API

Options

属性默认值默认值是否必填说明
container--canvas 容器
image--要渲染的图片

Functions & Props

  • setData(data: Shape[]) // 设置批注

  • update() // 更新视图

  • clean() // 清空批注

  • on(event: string, fn: Function) // 事件监听

  • createType: string // 设置当前批注类型

  • readonly: boolean // 设置只读状态

  • createLabelFillStyle: string // 设置当前批注文本的颜色

  • createRectStrokeStyle: string // 设置当前批注形状线条的颜色

  • activeShape: Shape // 获取/设置当前激活状态的批注

  • dataset: Shape[] // 获取当前批注内容

Shape

属性类型默认值说明
typestring-批注类型
labelstring-批注文字
coorArray<[number, number]>-点位坐标信息

Event

  • load // 图片加载完成
  • updated // 绘图过程
  • add // 绘图完成
  • delete // 删除批注
  cc.on('load', () => {
    // ...do something
  });

FAQs

Package last updated on 07 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc