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

michaelangelo

v0.1.2

Published

A lightweight wrapper for RaphaelJS.

Downloads

19

Readme

Michaelangelo

Michaelangelo enables you to easily build out cross-browser vector graphics via Raphael that was inspired by the Python module matplotlib.

Using

Currently, Michaelangelo provides abstractions some of the elements you can create in Raphael. The abstraction isn't much currently, but it provides namespacing and the ability to easily scale your graphics.

For the following code samples, I will demonstrate how you might fulfill the same task in Raphael vs. Michaelangelo.

// Vanilla Raphael
var Raphael;

Raphael = require('raphael');

// Create a 400x400 canvas with a 10x10 rectangle in the top left
Raphael(['canvas', 400, 400, {
  type: 'rect',
  x: 0,
  y: 0,
  width: 10,
  height: 10,
  stroke: '#000'
}]);
// Raphael with Michaelangelo
var Michaelangelo, Raphael, rectangle;

Michaelangelo = require('michaelangelo');
Raphael = require('raphael');

rectangle = Michaelangelo.Rectangle({
  x: 0,
  y: 0,
  width: 10,
  height: 10,
  {
    stroke: '#000'
  }
});

Raphael('canvas'. 400, 400, rectangle.toRaphaelObject());

Ok... I know what you're thinking. More lines of code... Wat?

You're right, but what if we want to scale our rectangle?

// Raphael with Michaelangelo
var Michaelangelo, Raphael, rectangle;

Michaelangelo = require('michaelangelo');
Raphael = require('raphael');

// Creates a 20x20 rectangle
rectangle = new Michaelangelo.Rectangle({
  x: 0,
  y: 0,
  width: 10,
  height: 10,
  {
    scale: 2,
    stroke: '#000'
  }
});

Raphael('canvas'. 400, 400, rectangle.toRaphaelObject());

The problem I had is that I wanted to use real measurements, then scale as needed.

Raphael provides means to scale, but you must do so after placing it on the canvas. Prior to placing it on the canvas, I didn't want to have to deal with the mental load of keeping track of the scale or litter '... * 2' everywhere.

While these may be syntactic improvements at best, I think some of the real powers of Michaelangelo reside in path building.

var Raphael;

Raphael = require('raphael');

Raphael(['canvas', 400, 400, {
  type: 'path',
  path: 'M0,0L10,10Z';
}]);

While this is a simple example, it's not entirely intuitive.

var Michaelangelo, Raphael, path;

Michaelangelo = require('michaelangelo');
Raphael = require('raphael');

path = new Michaelangelo.Path({
  x1: 0,
  y1: 0,
  x2: 10,
  y2: 10
});

Raphael('canvas'. 400, 400, path.toRaphaelObject());

To me, this example is much more clear of what we're doing. We have a line with two points, Michaelangelo handles the rest.

Another handy service that Michaelangelo provides is building arcs.

var Michaelangelo, Raphael, circle, ellipse, arc;

Michaelangelo = require('michaelangelo');
Raphael = require('raphael');

// Essentially draws a circle centered at (200, 200) with
// a radius of 25
circle = new Michaelangelo.Arc({
  cx: 200,
  cy: 200,
  height: 50,
  width: 50
});

// Similar to above, but this will be an ellipse
ellipse = new Michaelangelo.Arc({
  cx: 200,
  cy: 200,
  height: 100,
  width: 50
});

// Ok, now we're actually drawing an arc. This one will draw
// the right half of the ellipse above.
arc = new Michaelangelo.Arc({
  cx: 200,
  cy: 200,
  height: 100,
  width: 50,
  theta1: 90,
  theta2: 270
});

Future Development

  • Make Michaelangelo a module that can stand on it's own - currently still have to use Raphael in conjunction
  • Make scale an option that you configure once for the entire canvas
  • Expand the path helper functions
  • Make the canvas rotate easily

Contributing

Installing

git clone [email protected]:austburn/michaelangelo.git

cd michaelangelo

npm install

Run Tests and Lint

npm test

Feel free to fork and submit pull requests!