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

ahmux-scene-design

v0.0.1

Published

防区设计器

Downloads

3

Readme

场景设计器

基于 vue3.2typescript 的场景设计器

如何使用

# 安装依赖
yarn install ahmux-scene-design
import SceneDesign from 'ahmux-scene-design'

// 全局使用请用 Vue.use
Vue.use(SceneDesign)
<!-- 组件使用 -->
<scene-design ref="designRef" :shapes="shapes"></scene-design>

属性说明 id 为生成canvas的ID width 画布宽度 height画布高度 background画布背景色 shapes 为场景中的形状,格式为json字符串,可通过toJson方法获取 mouseListening 是否监听鼠标事件,默认为true,当为false时,鼠标事件不会触发

interface Props {
  id?: string,
  width?: number,
  height?: number,
  background?: string,
  shapes?: string,
  mouseListening?: boolean
}

方法说明

// 清除画布
clear()
// 撤销
revoke()
// 强制渲染
forceReDraw()
// 转换配置成json
toJson()
// 根据id获取形状
getShapeById(id)
// 获取图片
getImage()
// 根据类型获取图片
getImageByType(type)
// 添加形状 shape 为shape 类型
addShape(shape)
// 预添加形状,添加完毕后,可使用ctrl+鼠标 确定形状的初始位置
preAddShape(shapeProp)
//根据ID编辑对应的形状
editById(id, prop)
// 根据ID删除对应的详情
removeById()

内嵌类型

目前内置了以下类型,详细请参见类型定义,可根据需要自行扩展

Circle:圆形
Rectangle:矩形
TextShape:文字
DefenseArea:直角防区,不推荐使用
MultiDefenseArea:曲线防区
ImageShape:图片

对应数据结构如下

export interface ShapeProps {

}

export interface BaseShapeProps extends ShapeProps {
  id?: string;
  cloneId?: string;
  type?: string;
}

export interface RectangleProps extends BaseShapeProps {
  startX: number;
  startY: number;
  endX: number;
  endY: number;
  strokeWidth?: number;
  strokeColor?: string;
  fillColor?: string;
}

export interface CircleProps extends BaseShapeProps {
  x: number;
  y: number;
  radius: number;
  strokeWidth?: number;
  strokeColor?: string;
  fillColor?: string;
}

export interface DefenseAreaProps extends RectangleProps {
  markDistance: number;
  height: number;

}

export interface MultiDefenseAreaProps extends BaseShapeProps {
  points: Point[];

  height: number;
  strokeWidth?: number;
  strokeColor?: string;
  fillColor?: string;
}


export interface ImageShapeProps extends BaseShapeProps {
  x: number;
  y: number;
  height?: number;
  width?: number;
  url: string;
  fillColor?: string;
  strokeColor?: string;
}


export interface TextShapeProps extends BaseShapeProps {
  x: number;
  y: number;
  fontSize: number;
  fontFamily?: string;
  text: string;
  fillColor: string;
  maxWidth?: number;
  textAlign?: CanvasTextAlign;
  textBaseline?: CanvasTextBaseline;
  direction?: CanvasDirection;
}