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

@xylink/xy-whiteboard

v0.0.5

Published

XYLink Whiteboard

Downloads

5

Readme

XYLINK WHITEBOARD

项目介绍

白板

安装

# 通过 Yarn 安装
$ yarn add @xylink/xy-whiteboard

# 通过 Npm 安装
$ npm install @xylink/xy-whiteboard

#示例

import { Whiteboard } from '@xylink/xy-whiteboard';

const whiteboard = new Whiteboard({ containerId: 'container' });

/**
 * 白板配置
 *
 * @property { string } containerId - canvas父级元素的ID, 默认为body
 * @property { number } width - 白板宽度
 * @property { number } height - 白板高度
 * @property { BoardType } drawType - 绘制类型, 默认自由笔画
 */
interface WhiteboardConfig {
  containerId?: string;
  width?: number;
  height?: number;
  drawType?: DRAW_TYPE;
  config?: WhiteboardCommonConfig;
}

/**
 * 白板常规配置,包含样式配置等
 *
 * @property { string } backgroundColor - 画布背景颜色
 * @property { string } stroke - 线条颜色, 默认#000
 * @property { string } fill - 填充颜色, 默认transparent
 * @property { number } strokeWidth - 大小, 默认3
 * @property { number } scale - 画布的缩放值, 默认1
 * @property { number } maxScale - 画布的最大缩放值, 默认3
 */
interface WhiteboardCommonConfig {
  backgroundColor?: string;
  stroke?: string;
  fill?: string;
  strokeWidth?: number;
  scale?: number;
  maxScale?: number;
}

// 笔刷 
whiteboard.switchDrawType(DRAW_TYPE.PENCIL);

// 橡皮刷
whiteboard.switchDrawType(DRAW_TYPE.ERASER);

// 设置线条宽度
whiteboard.setStrokeWidth(size);

// 设置线条颜色
whiteboard.setStrokeColor(color);

// 清除整个白板
whiteboard.clear();

// 撤销
whiteboard.undo();

// 重做
whiteboard.redo();

// 选择, 设置后,可对元素进行选中,放大缩小旋转等;
whiteboard.switchDrawType(DRAW_TYPE.SELECTOR);

// 设置白板尺寸
whiteboard.setCanvasSize({ width: 557 , height: 236 , scale: false });

// 获取白板尺寸
whiteboard.getCanvasSize();

// 绘制JSON数据
 whiteboard.setCanvasByJson({
      attrs: {
        name: 'line',
        points: [
          {
            x: 126,
            y: 204
          },
          {
            x: 127,
            y: 204
          },
          {
            x: 128,
            y: 204
          },
          {
            x: 134,
            y: 204
          },
          {
            x: 145,
            y: 204
          },
          {
            x: 162,
            y: 204
          },
          {
            x: 184,
            y: 204
          }
        ],
        stroke: '#f00',
        strokeWidth: 3,
        tension: 0.5
      },
      className: 'Line'
    });


/**
 * 目前支持绘制类型
 *
 * @param { TOUCH } touch - 移动
 * @param { PENCIL } pencil - 笔
 * @param { RECT } rect - 矩形
 * @param { TRIANGLE } triangle - 三角形
 * @param { CIRCLE } circle - 圆形
 * @param { ARROW } arrow - 箭头
 * @param { ERASER } eraser - 橡皮刷
 * @param { TEXT } text - 文字
 * @param { SELECTOR } selector - 选择
 */
export enum DRAW_TYPE {
  TOUCH = 'touch',
  PENCIL = 'pencil',
  RECT = 'rect',
  TRIANGLE = 'triangle',
  CIRCLE = 'circle',
  ARROW = 'arrow',
  LINE = 'line',
  ERASER = 'eraser',
  TEXT = 'text',
  SELECTOR = 'selector'
}

on(eventName:EVENT , callback)


/**
 * 上报事件类型
 * 
 * @param { DRAW_TYPE } DRAW_TYPE - 绘制类型
 * @param { ACTION } ACTION - 操作类型
 * @param { DRAW_DATA } DRAW_DATA - 绘制数据
 */
export enum EVENT {
  DRAW_TYPE = 'DRAW_TYPE',
  ACTION = 'ACTION',
  DRAW_DATA = 'DRAW_DATA',
}

/**
 * 绘制数据
 *
 * @property { Object } attrs - 绘制数据
 * @property { string } className - 绘制类型
 */
export interface DrawJsonData {
  attrs: {
    [key: string]: any;
  };
  className: string;
}

| 事件名称 | 描述 | 回调参数 | | ------------------- | -------------------------------- | ---------------------------------------------------- | | DRAW_TYPE | 绘制类型 | string | | DRAW_DATA | 当前绘制数据 | DrawJsonData |

Changelog

0.0.1 (2023-10-24)

✨ Features | 新功能

  • 白板

0.0.3 (2023-11-14)

✨ Features | 新功能

  • 支持setCanvasSize和getCanvasSize方法

0.0.4 (2024-0319)

✨ Features | 新功能

  • 修复已知问题