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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cre8bitjs

v2.3.1

Published

Add svg retro video game characters to a web page

Downloads

57

Readme

Cre8bitJS

Cre8bitJS is a lightweight Javascript library that adds 8bit style retro video game characters to your web page as svgs. These are created dynamically allowing for customisation.

Note: This library is a Javascript class containing private fields and methods which may not work with your chosen minifier. For a minified* version of the library, install cre8bit-minified.

Setup

Via npm for use with a bundler.

$ npm install cre8bitjs --save
import cre8bit from 'cre8bitjs';

Usage

// The most basic usage of the library
new cre8bit().create('space invader');

Examples

// Create an svg with custom options
new cre8bit().create('pacman', {size: 12, parentClass: 'container'});

// Some helper methods are available if you need to modify the svg after creation
const pacman = new cre8bit().create('pacman');
pacman.setSize(20);
// Methods can be chained
pacman
  .setColour('#f9eb06')
  .setFlip(true);

// Animation option available for certain characters
const ghost = new cre8bit().create('ghost', {animate: true});
// Cancel animation
ghost.stop();

Character names

Pass one as the first argument to the create method.

  • 'space invader'
  • 'ufo'
  • 'pacman'
  • 'ghost'
  • 'poke ball'
  • 'pikachu'
  • 'mario'
  • 'mushroom'
  • 'kirby'

Look out for new characters.

Options

Optional object passed as the second argument to the create method.

(string) colour - Any valid CSS colour name or hex value e.g: red or #c8b. Characters have a default colour.

(number) size - Up to a maximum size of 70. The default is 5.

(boolean) flip - The default is false.

(boolean) animate - Only available currently with space invader, pacman & ghost.

(boolean) reflection - The default is false.

(string) parentClass - Use this to add the svg to an existing DOM element by providing the class name. If none is provided they are added to the document body.

(string) wrapperClass - Use this to wrap the svg in a div with the class name provided.

(boolean) outline - Add an outline to all paths of a character. Useful if there is not enough contrast between the character colour and your page background, or the character (parts of the character) are the same colour as your page.

(array) responsive - Pass an array of exactly 3 numbers for the size you want to display the character on mobile, tablet(768px) and desktop(1000px). E.g: [6, 8, 12]. All 3 values don't need to be different if, for example, you want to use the same size at tablet and desktop but you do still need to pass 3 values. E.g: [6, 12, 12].

Helper methods

setColour(string) - Any valid CSS colour name or hex value e.g: red or #c8b. Characters have a default colour.

setSize(number) - Up to a maximum size of 70. The default is 5.

setFlip(boolean) - The default is false.

stop() - Stop a currently animating character.

In action

See some examples of the library in use.

Try out the library in the Cre8bitJS Playground.

Browser support

Works in latest version of all major desktop browsers and latest version of major Android & IOS browsers.

* At the time of writing, a minifier that could handle private properties & methods could not be found, so a custom node minifying script was created, shaving nearly 40% off the unminified version.