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

obelisk.js

v1.2.2

Published

JavaScript Library for Building Pixel Isometric Element with HTML5 Canvas

Downloads

150

Readme

Obelisk.js

Travis GitHub release Codacy

obelisk.js is a JavaScript library for building isometric pixel objects.

With the simple and flexible API provided, you can easily add isometric pixel elements like brick, cube, pyramid and slope in HTML5 canvas. Obelisk.js strictly follows pixel neat pattern: lines with 1:2 pixel dot arrangement, leading to an angle of 22.6 degrees.

Also you should know obelisk.js is not for vector isometric graphics drawing and rendering. Internally it does not use any canvas graphic drawing API, instead, it manipulates all the rendering in pixel level to obtain precise pixel arrangement. Just try it out to pixelate something. Have fun.

1.2.0 Release

The newest version is written by CommonJS style, which means you can easily use it in browserify project. See details here

Showcase

Origin:

  • Input Text Rendering: http://codepen.io/nosir/details/IxBJn
  • GIF Animation Rendering: http://codepen.io/nosir/details/mdiHe (Safari only)
  • Pixel Isometirc Flappy Bird: http://codepen.io/nosir/details/rzaLA
  • Cube Generator: http://codepen.io/nosir/details/ganrh

User Contributed:

Getting started

Simply include obelisk.js in your project

<script src="//path/to/obelisk.min.js"></script>

In JavaScript

// create a canvas 2D point for pixel view world
var point = new obelisk.Point(200, 200);

// create view instance to nest everything
// canvas could be either DOM or jQuery element
var pixelView = new obelisk.PixelView(canvas, point);

// create cube dimension and color instance
var dimension = new obelisk.CubeDimension(80, 100, 120);
var gray = obelisk.ColorPattern.GRAY;
var color = new obelisk.CubeColor().getByHorizontalColor(gray);

// build cube with dimension and color instance
var cube = new obelisk.Cube(dimension, color, true);

// render cube primitive into view
pixelView.renderObject(cube);

For more details, check the tutorial part 1: To build the first cube, or try the code yourself

Tutorials

Step by step:

Sample code for building all primitives:

  • Cube: http://jsfiddle.net/nosir/ygWEW/
  • Pyramid : http://jsfiddle.net/nosir/ZVURu/
  • LineX, LineY, LineZ: http://jsfiddle.net/nosir/gnbqwr2L/
  • Brick: http://jsfiddle.net/nosir/6MuVr/
  • SideX, SideY: http://jsfiddle.net/nosir/bLsew/
  • SlopeNorth, SlopeEast, SlopeSouth, SlopeEast: http://jsfiddle.net/nosir/28B9G/

Development (Browser)

Browserify

Obelisk.js can be used from browserify project. Simply:

$ npm install obelisk.js

In your JavaScript

var obelisk = require('obelisk.js');

// Now you can do the same as above

Want to build the project locally?

$ git clone https://github.com/nosir/obelisk.js.git
$ npm install

Build

$ gulp build

Develop

$ gulp browserify:watch

Advanced Usage (Node.js)

Node.js

Also you can use it in your Node.js canvas project

As node.js canvas dependency can be tricky to install (binary dependency on Cairo) we are not adding it as a project dependency. You will need to add the canvas dependency explicitly on your project:

$ npm install canvas
$ npm install obelisk.js

In your JavaScript

// load Node Canvas dependency
var Canvas = require('canvas');

// load obelisk.js module
// here we need the Canvas as a module parameter
var obelisk = require('obelisk.js')(Canvas);

// create a Node Canvas instance
var canvas = new Canvas(600,450);

// Use obelisk the same way you will use it in the browser ...

// Save canvas to a file
canvas.createPNGStream().pipe(fs.createWriteStream('./figure.png'));

For more details, check the Node.js Canvas example.

Get in Touch

Changelog

See details here: release notes.

References

Pixel art is a form of digital art, where images are edited and displayed on the pixel level. The isometric projection is commonly seen in games to provide a 3D view without using any real 3D processing.

  • Isometric projection http://en.wikipedia.org/wiki/Isometric_projection
  • Flood fill implementation http://en.wikipedia.org/wiki/Flood_fill
  • Pixel grapic - Eboy http://eboy.com

License

Obelisk.js is released under the MIT License