0.1.4 • Published 6 years ago

microcan v0.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Microcan - micro framework for painless canvas

API Documentation

  • poly: (x, y, sides, radius)
  • setCanvasSize: (id, width, height)
  • fill: (ctx, r = 0, g = 0, b = 0, a = 255)
  • noFill: (ctx)
  • background: (ctx, r = 0, g = 0, b = 0, a = 255, w = 500, h = 500)
  • stroke: (ctx, r = 0, g = 0, b = 0, a = 255)
  • noStroke: (ctx)
  • strokeWeight: (ctx, weight)
  • line: (ctx, v, v2)
  • ellipse: (ctx, v, rx, ry = rx, oa = 0, sa = 0, ea = Math.PI * 2)
  • arc: (ctx, v, r, sa = 0, ea = Math.PI * 2)
  • drawPoly: (ctx, ps)
  • rect: (ctx, pos, w, h)

Patterns

Supplying the ctx argument can lead to noise. For a more pleasant usage, it's recomended to partially apply the ctx argument to all the functions:

const applyArgs = (obj, ...args) => {
  return Object.keys(obj).reduce((newObj, key) => {
    newObj[key] = (...nextArgs) => obj[key](...args, ...nextArgs);
    return newObj;
  });
};

const ctx = /* get the canvas context */
const {
  line,
  fill,
  strokeWeight
} = applyArgs(microcan, ctx);

line([0, 0], [100, 100]);
0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

7 years ago

0.0.1

7 years ago