GithubHelp home page GithubHelp logo

noscripter / obelisk.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nosir/obelisk.js

0.0 2.0 0.0 412 KB

JavaScript Library for Building Isometric Pixel Elements with HTML5 Canvas

License: MIT License

JavaScript 81.55% HTML 18.45%

obelisk.js's Introduction

Obelisk.js

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

With the simple and flexible API provided by it, you can easily add isometric pixel element like brick, cube, pyramid, slope onto HTML5 canvas. Obelisk.js strictly follows the 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. In fact it is not using any canvas graphic drawing API, instead, it manipulates all the things in pixel level to obtain precise pixel arrangement. Just try it out to pixelate something. Have fun.

Showcase

Origin:

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:

Advanced Usage

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.

Browserify

obelisk.js can also be used from a browserify project. Simply:

var obelisk = require('obelisk.js');
console.log(obelisk.Point)
// > function Point() { }

Get in Touch

Changelog

See details in the 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.

License

Obelisk.js is released under the MIT License

obelisk.js's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.