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

image-to-mosaic

v1.0.0

Published

A zero-dependency JavaScript library that transforms images into interactive mosaic tiles with customizable patterns, animations, and effects

Readme

image-to-mosaic

npm version npm bundle size License: MIT

A zero-dependency JavaScript/TypeScript library that transforms images into interactive mosaic tiles with customizable patterns, animations, and effects.

Live Demo

Features

  • 6 Mosaic Patterns: grid, brick, diamond, strips, voronoi, puzzle
  • 5 Animation Types: fade, scale, flip, slide, scatter
  • 4 Delay Modes: sequential, random, center, spiral
  • 8 Hover Effects: lift, glow, zoom, tilt, flip, blur, pop, spotlight
  • Interactivity: Drag & drop tiles, shuffle, click events
  • Web Component: Use as <mosaic-image> custom element
  • TypeScript: Full type definitions included
  • Zero Dependencies: Pure vanilla JavaScript/TypeScript
  • Lightweight: ~10KB gzipped

Installation

NPM

npm install image-to-mosaic

CDN (Script Tag)

<script src="https://unpkg.com/image-to-mosaic/dist/image-to-mosaic.umd.js"></script>

Quick Start

ES Modules

import { Mosaic } from 'image-to-mosaic';

const mosaic = new Mosaic({
  target: '#container',
  image: 'path/to/image.jpg',
  pattern: 'grid',
  density: 50,
  gap: 2,
  animation: {
    type: 'fade',
    delay: 'random',
    duration: 500,
    easing: 'ease-out',
  },
  hover: {
    effect: 'lift',
    scale: 1.08,
    duration: 200,
  },
});

mosaic.render();

Script Tag (UMD)

<!DOCTYPE html>
<html>
<head>
  <style>
    #container {
      width: 800px;
      height: 600px;
    }
  </style>
</head>
<body>
  <div id="container"></div>

  <script src="https://unpkg.com/image-to-mosaic/dist/image-to-mosaic.umd.js"></script>
  <script>
    const mosaic = new ImageToMosaic.Mosaic({
      target: '#container',
      image: 'path/to/image.jpg',
      pattern: 'brick',
      density: 30,
      animation: { type: 'scale', delay: 'center' },
      hover: { effect: 'glow' },
    });
    mosaic.render();
  </script>
</body>
</html>

Web Component

<script src="https://unpkg.com/image-to-mosaic/dist/image-to-mosaic.umd.js"></script>
<script>
  ImageToMosaic.registerMosaicElement();
</script>

<mosaic-image
  src="path/to/image.jpg"
  pattern="diamond"
  density="40"
  animation="fade"
  hover="lift"
  style="width: 800px; height: 600px;"
></mosaic-image>

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | target | string | HTMLElement | required | Container element or selector | | image | string | required | Image URL | | pattern | string | 'grid' | Pattern type: grid, brick, diamond, strips, voronoi, puzzle | | density | number | 50 | Tile density (1-100) | | gap | number | 2 | Gap between tiles in pixels | | borderRadius | number | string | 0 | Border radius for tiles | | animation.type | string | 'none' | Animation: fade, scale, flip, slide, scatter, none | | animation.delay | string | number | 'sequential' | Delay mode: sequential, random, center, spiral, or ms | | animation.duration | number | 500 | Animation duration in ms | | animation.easing | string | 'ease-out' | CSS easing function | | hover.effect | string | 'none' | Hover effect: lift, glow, zoom, tilt, flip, blur, pop, spotlight, none | | hover.scale | number | 1.1 | Scale factor for hover | | hover.duration | number | 200 | Hover transition duration in ms | | hover.color | string | undefined | Glow color (for glow effect only) | | draggable | boolean | false | Enable drag & drop | | shuffle | boolean | false | Start with shuffled tiles | | onReady | function | undefined | Callback when mosaic is ready | | onTileClick | function | undefined | Callback when tile is clicked | | onError | function | undefined | Callback when an error occurs |

Methods

// Re-render the mosaic
await mosaic.render();

// Shuffle tile positions
mosaic.shuffle();

// Reset to original positions
mosaic.reset();

// Change image
await mosaic.setImage('new-image.jpg');

// Change pattern
await mosaic.setPattern('voronoi');

// Change density
await mosaic.setDensity(75);

// Change animation
await mosaic.setAnimation('flip');

// Change hover effect
mosaic.setHoverEffect('zoom');

// Update multiple config options
await mosaic.updateConfig({ gap: 5, borderRadius: 10 });

// Destroy and cleanup
mosaic.destroy();

Browser Support

  • Chrome 60+
  • Firefox 55+
  • Safari 12+
  • Edge 79+

Author

Created by Manish Gupta

License

MIT