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

cubs.js

v0.3.10

Published

A light-weight canvas graphic lib.

Readme

🐯 cubs.js

🏠 Homepage

轻量级 canvas 绘图库

  • 轻量级模块化(按需引入,所有模块总和 gzip 8k)
  • DOM 风格的事件和样式接口
  • Shape 粒度的隔离与控制,场景树接口
  • 常见图元(点、线、折线、多边形、矩形、圆形、图片)
  • 鼠标交互工具、图形编辑工具、绘图工具

不对标 G 或 paper.js 等图形框架,不提供新的图形API,不封装底层图形接口

🎯 目标场景

适用场景:使用 canvas 开发交互式 2D 图形应用

目标用户:了解 canvas 接口,不希望引入大型框架、场景定义的开发者

🚀 Usage

const scene = new Scene(canvas)
scenePointerControl(scene) // add pointer control for view
addAxis(scene) // add coordinate axis

scene.addEventListener('pointerdown', (e) => {
	console.log('pointer down', e)
})

// shape
const shape = new RectShape()

shape.styles.fillStyle = 'red'
shape.hoverStyle.fillStyle = 'blue'

shape.addEventListener('pointerdown', (e) => {
	console.log('pointer down on shape', e)
})

scene.add(shape)

editRect(shape) // add edit tool for rect shape

📐 自定义 Shape

class MyShape extends Shape {
	hit(x: number, y: number, ctx: CanvasRenderingContext2D): boolean | undefined | object {
		const { x: localX, y: localY } = this.viewToLocal(x, y)

		// 使用 图形算法 或者 canvas Path2D 接口判断是否命中
		// 若命中,返回详细信息或者 true,否则返回 false 或者 undefined
	}

	draw(ctx: CanvasRenderingContext2D): void {
		// 使用 ctx 绘制图形
		// 使用 this.localToView(x, y) 将本地坐标转换为canvas坐标
	}
}