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

@erikwatson/bramble

v0.16.1

Published

A creative coding library.

Readme

Bramble

An intuitive creative coding library for the web.

Warning: Bramble does not have a stable 1.0.0 API yet. The API is still evolving and may change between releases. Avoid building anything ambitious on top of it until 1.0.0.

Features

Bramble provides a small set of APIs for building interactive graphics applications and games in the browser.

  • Game loop

    • update callbacks
    • render callbacks
    • delta time
  • Graphics

    • circles, rectangles and lines
    • curves
    • text
    • images and image regions
    • transforms
    • compositing effects
    • shadows and glows
    • blur and colour effects
  • Input

    • keyboard
    • mouse
  • Assets

    • data
    • images
    • sound
  • Audio

    • sound effects
  • Persistent state

    • save/load
  • Math

    • 2D vectors
    • collision detection

Some APIs are still experimental or unfinished and are not documented here yet.

Getting started

Install Bramble from npm:

npm install @erikwatson/bramble

Bramble can also be used directly in the browser with the standalone browser build.

Browser

The browser build exposes Bramble as a global:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Bramble</title>
</head>
<body>
  <div id="bramble-container"></div>

  <script src="./bramble.js"></script>
  <script src="./game.js"></script>
</body>
</html>

Then create a game with:

const game = Bramble.game.create()

ES modules

When using Bramble as an npm package:

import Bramble from '@erikwatson/bramble'

const game = Bramble.game.create()

CommonJS

Bramble also provides a CommonJS build:

const Bramble = require('@erikwatson/bramble')

const game = Bramble.game.create()

Your first game

Create a game, attach it to a container, configure its size, provide update and render callbacks, and start it:

const game = Bramble.game.create()

const container = document.getElementById('bramble-container')

game.attachTo(container)

game.setSize(800, 600)

game.setBackgroundColour('#111')

const player = {
  position: { x: 400, y: 300 },
  radius: 24
}

game.setUpdate(({ input, dt }) => {
  const speed = 300

  if (input.keyboard.left.pressed || input.keyboard.A.pressed) {
    player.position.x -= speed * dt
  }

  if (input.keyboard.right.pressed || input.keyboard.D.pressed) {
    player.position.x += speed * dt
  }

  if (input.keyboard.up.pressed || input.keyboard.W.pressed) {
    player.position.y -= speed * dt
  }

  if (input.keyboard.down.pressed || input.keyboard.S.pressed) {
    player.position.y += speed * dt
  }
})

game.setRender(({ gfx }) => {
  gfx.clear('#111')

  gfx.circle(player.position, player.radius, {
    fill: {
      colour: '#fff'
    },
    line: {
      width: 0
    }
  })
})

game.start()

This example uses the core game, input and graphics APIs.

Input

Keyboard state is available directly through input.keyboard.

Each key exposes four states:

input.keyboard.left.pressed
input.keyboard.left.justPressed
input.keyboard.left.released
input.keyboard.left.justReleased

For example:

game.setUpdate(({ input }) => {
  if (input.keyboard.space.justPressed) {
    // Jump
  }
})

Mouse state is available through input.mouse:

input.mouse.position
input.mouse.left.pressed
input.mouse.left.justPressed

Graphics

The graphics API is available through gfx in the render callback.

Basic shapes:

gfx.circle(position, radius, options)

gfx.square(position, size, options)

gfx.rect(rectangle, options)

gfx.line(from, to, options)

gfx.curve(from, to, controlPoints, options)

Text:

gfx.text(position, 'Hello, Bramble', {
  colour: 'white',
  size: 24,
  family: 'sans-serif'
})

Images:

gfx.image(image, position, size)

A region of an image can be drawn with subImage:

gfx.subImage(
  image,
  position,
  size,
  subPosition,
  subSize
)

This can be useful for drawing individual regions from a sprite sheet without using the higher-level sprite API.

Effects and transforms

Graphics operations can be wrapped in effects:

gfx.opacity(() => {
  gfx.circle({ x: 100, y: 100 }, 50, options)
}, 0.5)

Other available effects include:

gfx.shadow(...)
gfx.dodge(...)
gfx.overlay(...)
gfx.multiply(...)
gfx.screen(...)
gfx.blur(...)
gfx.colourShift(...)
gfx.strokeGlow(...)

Transforms can be applied to groups of drawing operations:

gfx.transform(() => {
  gfx.image(image, position, size)
}, {
  angle: 45,
  scale: 2,
  around: position
})

Individual rotation is also available:

gfx.rotate(() => {
  gfx.rect(rectangle, options)
}, angle, around)

Assets

Assets can be loaded and accessed through the game's asset system.

For example:

await game.assets.add('player', 'image', 'player.png')

The asset system supports images, sound and data.

Audio

Loaded sound assets can be played through the game's sound effects API:

sfx.play('laser')

and stopped with:

sfx.stop('laser')

Vectors

Bramble includes a small 2D vector API:

const position = Bramble.vec2.create(100, 100)

position.add({ x: 10, y: 20 })

position.multiplyScalar(2)

Vectors provide common operations such as addition, subtraction, multiplication, division, dot products, normalisation and length calculations.

TypeScript

Bramble is written in TypeScript and publishes type information.

Generated type documentation is available here:

Type Docs

Authors

Erik Watson