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

simple-canvas-library

v1.1.1

Published

A simple library for handling basic canvas drawings, callbacks, and animations.

Downloads

143

Readme

SimpleCanvasLibrary

A beginner-friendly TypeScript library for creating interactive canvas graphics, animations, and simple games. Perfect for learning game development concepts!

🚀 Quick Start

1. Create a canvas in your HTML:

<canvas id="my-game" width="800" height="600"></canvas>

2. Import and create a game:

import { GameCanvas } from "simple-canvas-library";

const game = new GameCanvas("my-game");

3. Add something to draw:

// Draw a bouncing ball
game.addDrawing(({ ctx, elapsed, width, height }) => {
  const x = (elapsed / 10) % width; // Move across screen
  const y = height / 2; // Middle of screen

  ctx.clearRect(0, 0, width, height); // Clear previous frame
  ctx.beginPath();
  ctx.arc(x, y, 20, 0, Math.PI * 2); // Draw circle
  ctx.fillStyle = "blue";
  ctx.fill();
});

4. Start the game loop:

game.run();

That's it! You now have an animated blue ball moving across the screen.

📚 Core Concepts

Drawing Functions

Every drawing function receives these helpful parameters:

  • ctx - The canvas drawing context
  • width, height - Current canvas size
  • elapsed - Milliseconds since the game started
  • timestamp - Current time
  • stepTime - Time since last frame
game.addDrawing(({ ctx, elapsed, width, height }) => {
  // Your drawing code here
});

Event Handling

Add interactive features easily:

// Handle clicks
game.addClickHandler(({ x, y, ctx, width, height }) => {
  console.log(`Clicked at ${x}, ${y}`);
  // Draw something at click position
});

// Handle mouse movement
game.addHandler("mousemove", ({ x, y }) => {
  console.log(`Mouse at ${x}, ${y}`);
});

// Handle key presses
game.addHandler("keydown", ({ key }) => {
  if (key === "Space") {
    console.log("Space pressed!");
  }
});

Sprites (Images)

Load and animate sprites easily:

import { Sprite } from "simple-canvas-library";

const playerSprite = new Sprite("player.png");

// Wait for image to load, then add to game
playerSprite.onReady(() => {
  game.addDrawing(({ ctx }) => {
    playerSprite.draw(ctx, 100, 100); // Draw at position (100, 100)
  });
});

🎮 Interactive Demos

Check out live examples at: https://thinkle.github.io/simple-canvas-library/demos/

📖 Full API Documentation

For complete method documentation, see: https://thinkle.github.io/simple-canvas-library/docs/

🎯 Perfect For

  • Learning game development - Simple, clear API
  • Teaching programming - Great for computer science classes
  • Rapid prototyping - Get ideas running quickly
  • Creative coding - Focus on creativity, not boilerplate

💾 Installation

Option 1: ES Modules (Recommended)

import { GameCanvas, Sprite } from "simple-canvas-library";

Option 2: Script Tag (for CodePen/JSFiddle)

<script src="https://unpkg.com/simple-canvas-library/dist/simple-canvas-library.umd.js"></script>
<script>
  const { GameCanvas, Sprite } = SimpleCanvasLibrary;
</script>

Option 3: npm

npm install simple-canvas-library

🏆 What Makes This Special

  • Zero configuration - No build step required
  • Beginner-friendly - Clear, simple API
  • TypeScript ready - Full type support
  • Lightweight - Small bundle size
  • Modern - ES modules, clean code
  • Educational - Perfect for learning

🤝 Contributing

Found a bug or want to add a feature? Check out our GitHub repository!


Made with ❤️ for students, teachers, and creative coders