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

drawing-viewer

v0.0.1

Published

# Build 编译

Downloads

1

Readme

二维原理图可视化

Build 编译

重要!!!

在 build 之前,需要将 src/lib 文件夹中的 hammer.js 的内容替换掉 node_modules/hammerjs 中的 hammer.js 文件!!!

pnpm install

pnpm build

Integration 集成

编译过后得到一个 dist 目录,将 dist 目录整个复制到需要使用的项目中。

复制到别的项目中建议改个名字,比如将 dist --> lib

集成至 Vue2

  1. 将目录中的 font 文件夹拖入至 Vue 项目中 public 文件夹中
  2. 在组件的 mounted() 生命周期中挂载
  3. 设置字体路径
export default {
    name: 'HelloWorld',
    props: {
        msg: String,
    },
    mounted() {
        const app = new App();
        app.setFontURL('simHei', '/font/simhei.ttf');
        app.setFontURL('newSimSun', '/font/NSimSun-02.ttf');
        app.setFontURL('SimSun (TrueType)', '/font/SimSun-01.ttf');
        app.setFontURL('Monospac821 BT', '/font/MONOSPACE821BT.ttf');
        app.mountTo(this.$refs.root);
    },
};

使用

与 npm 包类似,直接 import 引入即可

import { App } from '../lib';

const app = new App();
app.mountTo(ele); //ele是HTML元素

相关 API

  • 更改图元颜色: app.updateColor(symbolId: number, r: number, g: number, b: number, a: number): void

  • 更改图元透明度: app.updateTransparency(symbolId: number, transparency: number): void

r, g, b, transparency 范围均在 0~255

  • 选择图元:app.selectSymbol(symbolId: number): void

  • 聚焦图元并居中显示:app.focusSymbol(symbolId: number): void

  • 加载图纸:app.loadDrawing(drawingData: DrawingJSON): void

  • 新增、修改字体路径:setFontURL(fontName: string, url: string): void

  • 修改图纸背景色:setBackgroundColor(r: number, g: number, b: number, a: number): void

2022.12.30 新特性

  1. 提供二维原理图加载完成后的回调功能:

提供了一个 DRAWING_LOADED的事件,监听该事件即可。

const app = new App();
app.on(App.DRAWING_LOADED, () => {
    console.log('加载完成!');
});
  1. 提供二维原理图复位功能
app.resetCanvas();
  1. 提供背景色设置,同之前的 API setBackgroundColor,新增了透明度参数。

  2. 提供二维原理图关闭或画布关闭时的销毁功能

app.destroy();
  1. 提供清楚所有高亮节点功能
app.cancelHighlightNode();
  1. 提供鼠标选择图元时返回 symbolID, orilID, nodeID
test.on(App.SELECT_SYMBOL_ACTIVE, ids => {
    console.log(ids.symbolId);
    console.log(ids.orilId);
    console.log(ids.nodeId);
});
  1. 提供修改图元颜色,支持 RGBA,同之前的 API updateColor,新增了透明度参数

  2. 设置选中高亮颜色为红色,新增了 API setHighlightColor(r: number, g: number, b: number, a: number) 可以设置高亮颜色。

app.setHighlightColor(255, 100, 100, 255);