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

get-qubo

v1.1.0

Published

Visual hash avatars with bayer dithering and traditional Japanese colors

Downloads

706

Readme

Qubo

Visual hash avatars with Bayer dithering and traditional Japanese colors from Nippon Colors.

Each avatar is deterministically generated from a string (username, email, ID) — the same input always produces the same avatar. Colors are selected from 250 traditional Japanese colors and rendered as OKLCH monotone gradients with an adjustable ordered dither pattern.

npm version

Features

  • Deterministic — same input always generates the same avatar
  • 250 traditional Japanese colors from nipponcolors.com
  • OKLCH color space for perceptually uniform monotone gradients
  • Bayer ordered dithering (4x4 or 8x8 matrix)
  • Adjustable — control dither strength, pixel size, matrix type, and output size
  • Zero dependencies — pure TypeScript, no external libraries
  • Tiny bundle — ~8KB gzipped
  • TypeScript types included

Install

pnpm add get-qubo
npm install get-qubo
yarn add get-qubo

Quick Start

import { qubo } from "get-qubo"

const { canvas, color } = qubo("Kairo")
document.body.appendChild(canvas)

console.log(color.name)  // e.g. "nakabeni"
console.log(color.cname) // e.g. "中紅"
console.log(color.color) // e.g. "#DB4D6D"

API

qubo(name, options?)

Generates an avatar and returns a canvas element plus the matched Japanese color.

const { canvas, color } = qubo("Sora", {
  size: 256,
  matrix: "bayer4x4",
  strength: 0.8,
  pixelSize: 3,
})

Returns: { canvas: HTMLCanvasElement, color: NipponColor }

quboDataURL(name, options?)

Generates an avatar and returns it as a base64 PNG data URL. Useful for <img> tags or storing in a database.

import { quboDataURL } from "get-qubo"

const src = quboDataURL("Hikari", { size: 128 })
document.querySelector("img").src = src

Returns: string (data URL)

quboBlob(name, options?)

Generates an avatar and returns it as a PNG Blob. Useful for file uploads or FormData.

import { quboBlob } from "get-qubo"

const blob = await quboBlob("Kumo", { size: 512 })
const formData = new FormData()
formData.append("avatar", blob, "avatar.png")

Returns: Promise<Blob>

quboRender(canvas, name, options?)

Renders an avatar into an existing canvas element. Useful for frameworks like React where you manage the canvas ref.

import { quboRender } from "get-qubo"

const canvas = document.getElementById("my-canvas")
const color = quboRender(canvas, "Ren", { size: 200 })

Returns: NipponColor

quboURL(baseURL, name, options?)

Builds an API URL for use in <img> tags. Point this at your deployed Qubo instance.

import { quboURL } from "get-qubo"

const url = quboURL("https://qubo.example.com", "Aoi", {
  size: 200,
  matrix: "bayer4x4",
})
// => "https://qubo.example.com/api/avatar?name=Aoi&matrix=bayer4x4&size=200"

Returns: string

Options

| Option | Type | Default | Description | | -------------- | -------------------------- | ------------ | --------------------------------------------------------------------------- | | size | number | 200 | Output size in pixels | | matrix | "bayer4x4" \| "bayer8x8" | "bayer4x4" | Dither matrix type | | strength | number (0–1) | 0.8 | Dither strength (0 = smooth, 1 = max) | | pixelSize | number (1–8) | 3 | Size of each dither "pixel" block | | borderRadius | number | size / 2 | Corner radius in pixels. 0 = square, size / 2 = fully round (default). |

Squared avatars

The default is a fully round avatar (borderRadius = size / 2). For a square or rounded-square shape, pass borderRadius explicitly:

// Fully square
quboDataURL("Kairo", { size: 256, borderRadius: 0 })

// Rounded square (e.g. 16px corners on a 256px avatar)
quboDataURL("Kairo", { size: 256, borderRadius: 16 })

Note: The shape is baked into the PNG itself — transparent pixels outside the rounded rectangle. You do not need to also apply border-radius in CSS.

Framework Examples

React

import { useRef, useEffect } from "react"
import { quboRender } from "get-qubo"

function Avatar({ name, size = 48 }: { name: string; size?: number }) {
  const ref = useRef<HTMLCanvasElement>(null)

  useEffect(() => {
    if (ref.current) {
      quboRender(ref.current, name, { size: size * 2 })
    }
  }, [name, size])

  return (
    <canvas
      ref={ref}
      style={{
        width: size,
        height: size,
        borderRadius: "50%",
        imageRendering: "pixelated",
      }}
    />
  )
}

Vue

<script setup lang="ts">
import { ref, onMounted, watch } from "vue"
import { quboRender } from "get-qubo"

const props = defineProps<{ name: string }>()
const canvas = ref<HTMLCanvasElement>()

function render() {
  if (canvas.value) quboRender(canvas.value, props.name, { size: 200 })
}

onMounted(render)
watch(() => props.name, render)
</script>

<template>
  <canvas ref="canvas" style="width:48px;height:48px;border-radius:50%;image-rendering:pixelated" />
</template>

Svelte

<script lang="ts">
  import { onMount } from "svelte"
  import { quboRender } from "get-qubo"

  export let name: string
  let canvas: HTMLCanvasElement

  onMount(() => quboRender(canvas, name, { size: 200 }))
  $: if (canvas) quboRender(canvas, name, { size: 200 })
</script>

<canvas bind:this={canvas} style="width:48px;height:48px;border-radius:50%;image-rendering:pixelated" />

Default Profile Image on Signup

import { quboDataURL } from "get-qubo"

async function createUser(name: string, email: string) {
  const avatar = quboDataURL(name, { size: 256 })

  await db.users.create({
    name,
    email,
    avatar, // base64 PNG — store directly or upload to S3/R2
  })
}

Advanced Exports

For lower-level use, the following are also exported:

import {
  // Color data
  NIPPON_COLORS,       // Full array of 250 Japanese colors
  type NipponColor,    // { id, name, cname, color }

  // Hashing
  hash,                // Deterministic hash function
  hashValues,          // Multiple hash-derived values from a string

  // Color conversion
  hexToOklch,          // Hex → OKLCH
  oklchToHex,          // OKLCH → Hex
  generateMonotoneGradient, // Generate gradient palette from a color

  // Dithering
  shouldDither,        // Per-pixel dither decision
  type DitherOptions,
  type DitherMatrix,

  // Core renderer
  renderAvatar,        // Full avatar renderer
  type AvatarConfig,
} from "get-qubo"

How It Works

  1. Hash — The input string is hashed using a deterministic hash function (cyrb53) to produce stable numeric values
  2. Color Selection — Hash values select a color from the 250 traditional Japanese colors
  3. Gradient — An OKLCH monotone gradient is generated from the selected color, varying lightness while preserving hue
  4. Dither — A Bayer ordered dithering matrix creates the pixel pattern, with the gradient direction determined by the hash
  5. Render — The result is drawn pixel-by-pixel onto a canvas, masked to a circle

Development

# Install dependencies
pnpm install

# Start dev server
pnpm dev

# Build website + SDK
pnpm build

# Build SDK only
pnpm run build:lib

Tech Stack

  • TypeScript — type-safe throughout
  • Vite — dev server and build
  • Tailwind CSS v4 — styling with shadcn/ui theme
  • Canvas API — pixel-level rendering
  • OKLCH — perceptually uniform color space

License

MIT