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 🙏

© 2025 – Pkg Stats / Ryan Hefner

miniprogram-canvas-sugarjs

v1.0.4

Published

打造一个致力于微信小程序的Canvas库,类似于H5原生JS Canvas库-FabricJS

Readme

miniprogram-canvas-sugarjs

使用此组件需要依赖依赖开发者工具的 npm 构建。具体详情可查阅微信小程序官方npm文档

介绍

打造一个致力于微信小程序的Canvas库,类似于H5原生JS Canvas库 - FabricJS

开发进度

开发中...

使用方法

  1. 安装组件
npm install --save miniprogram-canvas-sugarjs
  1. .wxml
<canvas id="sugarjs"
        type="2d"
        disable-scroll="true"
        bindtouchstart="touchstart"
        bindtouchmove="touchmove"
        bindtouchend="touchend"
        style='width: {{width}}px; height: {{height}}px;'>
</canvas>
  1. 在.js文件中引用
const sugar = require('miniprogram-canvas-sugarjs')

Page({
  data: {
    width: windowWidth,
    height: 500,
  },
  onReady() {
    const query = wx.createSelectorQuery()
    query.select(`#sugarjs`).fields({node: true, size: true}).exec(res => {
      const canvas = res[0].node
      this.sugar = new sugar.Canvas({
        canvas: canvas,
        width: this.data.width,
        height: this.data.height,
        backgroundColor: 'skyblue'
      })
    })
  }
})

功能清单

  1. canvas主体
  • [x] 初始化(宽高、背景)
  • [ ] 其他...
  1. 图层类
  • [x] 基类ObjectClass
  • [x] 图片ImageClass
  • [x] 文本TextClass
  • [x] 矩形RectClass
  • [x] 三角形TriangleClass
  • [x] 多边形PolygonClass
  • [x] 圆CircleClass
  • [x] 椭圆EllipseClass
  • [ ] 直线LineClass
  • [ ] 群组GroupClass
  • [ ] 其他...
  1. 操作
  • [x] 增删
  • [x] 点击图层进入选中状态(显示图层边框控件)
  • [x] 拖动
  • [x] 缩放
  • [x] 旋转
  • [x] 翻转
  • [ ] 图层层级管理(上移、下移、置顶、置底)
  • [ ] 文本内容编辑
  • [ ] 其他...
  1. 事件监听
  • [x] canvas初始化周期事件
  • [x] 手指触摸事件
  • [ ] 清单3中的操作事件的监听
  • [ ] 其他...
  1. 拓展、增强功能
  • [ ] 状态存储(撤销undo、恢复redo)
  • [ ] 导入、导出canvas数据
  • [x] toDataURL生成图片
  • [ ] 手势缩放、旋转
  • [ ] 动画
  • [ ] 其他...