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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wecity/img-mark

v1.0.0

Published

图片标注工具

Downloads

5

Readme

@wecity/img-mark

npm i @wecity/img-mark -S

@wecity/img-mark是一个二次封装的图片标注工具

imgMark

imgMark.initMap

初始化画布,返回Promise

<div id='cvs'></div>  

import { imgMark } from '@wecity/img-mark'
const gmap = await imgMark.initMap({ id: 'cvs', img: pic, options: { zoom, mode: 'BAN' } })

| 字段名 | 类型 | 描述 | | :---- | :--- | :--- | | id | object | map container | | img | png/gif等 | 标注图片 | | options | object | 配置项 |

imgMark.initImg

初始化标注图片,返回Promise

<div id='cvs'></div>  

import { imgMark } from '@wecity/img-mark'
const gmap = await imgMark.initMap({ id: 'cvs', img: pic, options: { zoom, mode: 'BAN' } })
const imgLayer = await imgMark.initImg({ img: pic, map: gMap })

| 字段名 | 类型 | 描述 | | :---- | :--- | :--- | | map | gMap | gMap | | img | png/gif等 | 标注图片 | | zIndex | int | 层级 |

imgMark.initFeature

初始化Feature,返回Promise

<div id='cvs'></div>  

import { imgMark } from '@wecity/img-mark'
const gmap = await imgMark.initMap({ id: 'cvs', img: pic, options: { zoom, mode: 'BAN' } })
const imgLayer = await imgMark.initImg({ img: pic, map: gMap })
const featureLayer = await imgMark.initFeature({ map: gMap, img: pic, registerEvt: true })

| 字段名 | 类型 | 描述 | | :---- | :--- | :--- | | map | gMap | gMap | | img | png/gif等 | 标注图片 | | zIndex | int | 层级 |
| registerEvt | boolean | 默认注册一些通用的事件 |

registerEvt注册事件

  1. 标注新增、编辑上图
  2. 选中图层
    map.events.on('featureSelected', feature => {
      map.setActiveFeature(feature);
    })
    map.events.on('featureUnselected', () => {
      map.setActiveFeature(null);
    })
    map.events.on('featureUpdated', (feature, shape) => {
      feature.updateShape(shape);
    })
    map.events.on('drawDone', async (type, data) => {
      const drawingStyle = map.drawingStyle
      const uuid = utils.getUuid(type)
      if (FEATURE_MODULE.includes(type)) {
        const module = utils.bigCamel(type)
        const instance = new AILabel.Feature[module](
          uuid, // id
          getModeData(type, data), // shape
          {name: uuid}, // props
          drawingStyle // style
        )
        feature.addFeature(instance)
      }
    })

imgMark.binExtraData

绑定自定义数据大屏props到feature | 字段名 | 类型 | 描述 | | :---- | :--- | :--- | | any | any | 自定义数据 |

// 设置
const instance = new AILabel.Feature[module](
    uuid, // id
    shape, // shape
    { name: uuid, extra: this.extraData }, // props
    drawingStyle // style
)
feature.addFeature(instance)


// 获取
feature = {
    props: {
        extra: ''
    }
}   

utils

| 方法名 | 参数 | 描述 | | :---- | :--- | :--- | | bigCamel | str => string | 字符串转大驼峰,如: Camel | | getUuid | str => string | uuid | | getImgInfo | image | 获取图片信息:宽高等, 返回promise |
| hex2rgb | color(16进制), 透明的 | 16进制转rgba |

import { utils } from '@wecity/img-mark' 

utils.bigCamel('CAMEL') // Camel
utils.bigCamel('camel') // Camel

其他包含ailabel方法

import AILabel from 'ailabel'
const imgMark = {
  ...AILabel
}
export default imgMark