Skip to content

shundroid/matter-lines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

matter-lines

Lines for matter.js

Getting Started

$ npm install --save matter-lines

(matter.js, poly-decomp.js required)

import { Engine, Render, World, Bodies } from "matter-js";
import Line from "matter-lines";

document.addEventListener("DOMContentLoaded", () => {
  // create an engine
  const engine = Engine.create();

  // create a renderer
  const render = Render.create({
    element: document.body,
    engine
  });

  // create a line
  const line = new Line(engine.world, [
    // points
    { x: 50, y: 50 },
    { x: 100, y: 50 },
    { x: 100, y: 100 }
  ]);

  // run the engine
  Engine.run(engine);

  // run the renderer
  Render.run(render);
});

Examples

Coming soon.

Documentation

new Line(world, [defaultPoints = []], [lineWidth = 10], [miterLimit = 10])

  • world Matter.World : A world of matter.js
  • defaultPoints Matter.Vector[] : First added points
  • lineWidth number : Width of the line. See MDN
  • miterLimit number : See MDN

Line.prototype.addPoint(point)

Add a point to the line.

  • point Matter.Vector : Added point

Releases

No releases published

Packages

No packages published