Skip to content
Dan Marshall edited this page May 30, 2015 · 23 revisions

#Key Concepts of Maker.js

Maker.js lets you design shapes with JavaScript code. These shapes have only outlines. Shapes are made from primitive outlines called Paths. There are 3 primitive Paths: line, circle, and arc. Paths are defined by Points and other properties. A group of paths may be contained in what is called a Model. A Model may then contain other Models.

There is no concept of contiguity between paths.

POJO's: Plain old JavaScript objects are used to design your model. To make this work, these plain objects must conform to a schema.

Point

{ x: number, y: number }

example:

var myPoint = { x: 42, y: 99 };

Paths

Paths must contain these properties at a minimum:

  • type: string
  • id: string
  • origin: Point

Line path

{ type: "line", id: string, origin: Point, end: Point }

example:

var myLine = {type:"line", id:"myLine1", origin:{x:0, y:0}, end:{x:42, y:99}};

Circle path

{ type: "circle", id: string, origin: Point, radius: number }

example:

var myCircle = {type:"circle", id:"myCircle1", origin:{x:0, y:0}, radius:13};

Arc path

{ type: "arc", id: string, origin: Point, radius: number, startAngle: number, endAngle: number }

example:

var myArc = {type:"arc", id:"myArc1", origin:{x:0, y:0}, radius:4.2, startAngle:45, endAngle:135};

Clone this wiki locally