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 🙏

© 2026 – Pkg Stats / Ryan Hefner

momoi-layer

v0.1.1

Published

Tile-based layer compositing engine with raster, vector, and group layers

Readme

momoi-layer

タイルベースのレイヤー合成エンジン(ラスター、ベクター、グループ対応)

インストール

npm install momoi-layer

クイックスタート

import {
  LayerStack, RasterLayer, GroupLayer, Compositor
} from 'momoi-layer'

// レイヤースタックを作成
const stack = new LayerStack()

// ラスターレイヤーを追加
const bg = new RasterLayer('背景')
bg.setPixel(10, 20, 255, 0, 0, 255)  // 赤いピクセル
stack.addLayer(bg)

const fg = new RasterLayer('前景')
fg.blendMode = 'multiply'
fg.opacity = 0.8
fg.setPixel(10, 20, 0, 255, 0, 255)  // 緑のピクセル
stack.addLayer(fg)

// 合成
const compositor = new Compositor(stack)
compositor.compositeAll()

// 結果を取得
const projection = compositor.getProjection()

API リファレンス

Tile / TileMap

64x64 RGBA タイルによるスパースピクセルストレージ。描画済みタイルのみメモリ確保。

| エクスポート | 説明 | |---|---| | Tile | 64x64 RGBA タイル (getPixel, setPixel, clone, isEmpty) | | TileMap | タイルのスパースマップ + ダーティフラグ管理 | | TILE_SIZE | タイル1辺のサイズ (64) | | TILE_BYTES | タイル1枚のバイト数 (16,384) |

レイヤー

| エクスポート | 説明 | |---|---| | Layer | レイヤー基底クラス (opacity, visible, blendMode, locked, alphaLock, clipping) | | RasterLayer | TileMap ベースのピクセルレイヤー (setPixel, getPixel) | | VectorLayer | パスデータ + ラスタライズキャッシュ | | VectorPath | ベクターパス(制御点 + 筆圧) | | GroupLayer | 子レイヤーを持つフォルダ型レイヤー (passThrough 切替可能) |

合成

| エクスポート | 説明 | |---|---| | LayerStack | レイヤーツリー管理 (addLayer, removeLayer, findById) | | Compositor | タイルベース合成エンジン (compositeAll, compositeDirty) | | blendPixel | ピクセル単位のブレンド関数 |

| エクスポート | 説明 | |---|---| | BlendMode | 16 ブレンドモード ('normal', 'multiply', 'screen', 'overlay', 'add' 等) | | LayerType | 'raster' \| 'vector' \| 'group' | | PathPoint | ベクターパスの制御点 (x, y, pressure) |

サンプル

Canvas Demo

ブラウザ上でレイヤー合成の結果をリアルタイムにプレビューできるデモアプリです。

  • グラデーション背景 + チェッカーパターン(Overlay)
  • RGB 3色の円を GroupLayer でグループ合成
  • VectorLayer による波線描画
  • ブレンドモード・不透明度・表示切替の UI 操作
cd examples/canvas-demo
npm install
npm run dev

ブラウザで http://localhost:5173 を開くとデモが表示されます。

コマンド

npm run build       # tsup で ESM/CJS/型定義をビルド
npm run typecheck   # TypeScript 型チェック
npm test            # vitest でテスト実行
npm run test:watch  # vitest ウォッチモード

ライセンス

MIT