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

@mikixing/crk

v0.1.2

Published

canvas rendering kit

Downloads

1

Readme

CRK

crk (canvas rendering kit, canvas 渲染工具集) 是基于原生 canvas api 的超轻量绘制引擎, 包含完整 图形类, 事件系统, 矩阵系统, 可轻松实现 canvas 中的各种图形绘制

demo

安装

// npm
npm i @mikixing/crk

// yarn
yarn add @mikixing/crk

API

API 文档

示例

绘制闭合图形

import { Shape, Group, Stage } from '@mikixing/crk'

const stage = new Stage(canvas)
const shape = new Shape()
const grp = new Group()

grp.addChild(shape)
stage.addChild(grp)

shape.graphics
  .setStrokeStyle({
    color: '#f70',
    lineWidth: 2,
    gap: 'round',
    join: 'round',
  })
  .setFillStyle('#6cf')
  .moveTo(50, 300)
  .bezierCurveTo(80, 70, 260, 50, 310, 300)
  .closePath()
  .stroke()
  .fill()
stage.update()

对比 easeljs

crk 在部分接口定义上, 借鉴了 easeljs, 但内部实现原理完全不同, 主要包含以下几点:

  • 轻量 - crkGzip 压缩后体积仅为 8KB, 但却包含了 canvas 图形绘制中最重要的 图形类, 事件, 矩阵
  • 支持填充规则 winding rule, easeljs 常因无法设置此功能而让人诟病, 这也是我开发 crk 的一大原因. crkgraphics 模块尽量模拟原生 canvas api 写法
  • 不支持*Filter、 StageGL、Spirite 等 - 个人觉得这些功能对于一个功能纯粹的 2D 渲染库意义不大, 可拆分到独立的项目中, 或由业务开发实现

协议

MIT