View the official project page or try it out.
Isomer is an easy-to-use graphics library for drawing isometric scenes.
var Shape = Isomer.Shape;
var Point = Isomer.Point;
var Color = Isomer.Color;
var red = new Color(160, 60, 50);
var blue = new Color(50, 60, 160);
iso.add(Shape.Prism(Point.ORIGIN, 3, 3, 1));
iso.add(Shape.Pyramid(Point(0, 2, 1)), red);
iso.add(Shape.Prism(Point(2, 0, 1)), blue);
First, grab a copy of Isomer here. You can also pay for it. Then, include the script wherever you see fit:
<script src="/path/to/isomer.min.js"></script>
After which you'll need to place a canvas in your document that we can later refer to. Be sure to give it a width and height.
<canvas width="800" height="600" id="art"></canvas>
Note (Optional): To improve the look of your canvas on retina displays, declare the width and height of your canvas element as double how you want it to appear. Then style your canvas with CSS to include the original dimensions.
#art {
width: 400px;
height: 300px;
}
At this point we can finally instantiate an Isomer object. Pass it a reference to your canvas like so:
var iso = new Isomer(document.getElementById("art"));
Now you're ready to start drawing!
Isomer uses Gulp as a build tool. To build the project, first install the dependencies.
$ npm install
Then run npm run build
:
$ npm run build
> [email protected] build /Users/jordan/Projects/isomer
> gulp
[gulp] Using gulpfile ~/Projects/isomer/gulpfile.js
[gulp] Starting 'build'...
[gulp] Finished 'build' after 7.24 ms
[gulp] Starting 'default'...
[gulp] Finished 'default' after 7.04 μs
To generate isomer.js
in the build/
directory. For a minified build,
run npm run release
:
$ npm run release
> [email protected] release /Users/jordan/Projects/isomer
> gulp release
[gulp] Using gulpfile ~/Projects/isomer/gulpfile.js
[gulp] Starting 'build'...
[gulp] Finished 'build' after 7.11 ms
[gulp] Starting 'release'...
[gulp] Finished 'release' after 6.77 ms
This will generate build/isomer.min.js
.
Isomer is developed using Browserify. Install dependencies and build the project like so:
$ npm install
$ npm run build
test/index.html contains a basic testing page that draws various shapes. This page will load the unminified bundle.
The test
script (accessible via npm test
) uses beefy to automatically rebuild Isomer on any file changes. This script also opens the testing page (located at http://localhost:9966/test/
) in your default browser. The testing page includes a live reload script to refresh when Isomer is rebuilt.
$ npm test
> [email protected] test /Users/jordan/Projects/isomer
> open http://localhost:9966/test/ && ./node_modules/.bin/beefy index.js:build/isomer.js --live -- --standalone Isomer
listening on http://localhost:9966/
200 62ms 1.18KB /test/
200 11ms 508B /test/style.css
200 2ms 5.48KB /test/test.js
200 625ms 48.5KB /build/isomer.js -> ./node_modules/.bin/browserify ./index.js --standalone Isomer -d
Isomer also accepts the canvas provided by node-canvas, meaning you can generate isometric graphics on the command line.
var Canvas = require('canvas');
var canvas = new Canvas(400, 400);
var Isomer = require('isomer'); // npm install isomer
var fs = require('fs');
var out = fs.createWriteStream('output.png');
var iso = new Isomer(canvas);
iso.add(Isomer.Shape.Prism(Isomer.Point.ORIGIN));
canvas.pngStream().pipe(out);
For more info, check out the official project page.