0.0.2-dev.2 • Published 1 year ago

mraph v0.0.2-dev.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

npm GitHub last commit

Mraph.js is my poor rendering engine for drawing geometric shapes in a browser, inspired by manim
Github | NPM | Examples

Usage

Install with npm:

npm install --save mraph

or use yarn:

yarn add mraph

A short example:

Once you installed, try this example below.

import * as MRAPH from "mraph";

// Creates a new layer
const layer = new MRAPH.Layer().appendTo(document.body);

// Creates some points and sets their position
const pointsNum = 50;
const layersNum = 5;
const angleUnit = (Math.PI * 2) / pointsNum;
for (let j = 0; j < layersNum; j++) {
    for (let i = 1; i <= pointsNum; i++) {
        const point = new MRAPH.Point(Math.cos(angleUnit * i) * (3 + j * 2), Math.sin(angleUnit * i) * (3 + j * 2));
        layer.add(point);

        point.setColor(new MRAPH.Color(Math.random(), Math.random(), Math.random()));
    }
}

// Adds those points to the layer
layer.scene.children.forEach((point) => {
    layer.add(point);
});

// Sets an infinity event
// This event will remain perpetually active
layer.timeline.addInfinity(() => {
    layer.scene.children.forEach((point, i, arr) => {
        point.a = point.center.mult((-1 * i) / arr.length);
    });
});

// Starts playing animation
layer.enableOrbitControl().enableRotate = false;
layer.play();

Input this code in your preferred text editor. If all proceeds as it should, you will observe a series of dots engaged in a, hmm..., rather peculiar dance.

See more (not such dances)

Contribution

Feel free to contribute to this repo

0.0.2-dev.2

1 year ago

0.0.2-dev.1

1 year ago

0.0.1

1 year ago

0.0.1-dev.9

1 year ago

0.0.1-dev.8

1 year ago

0.0.1-dev.7

1 year ago

0.0.1-dev.6

1 year ago

0.0.1-dev.5

1 year ago

0.0.1-dev.4

1 year ago

0.0.1-dev.3

1 year ago

0.0.1-dev.2

1 year ago

0.0.1-dev.1

2 years ago

1.0.2-alpha.1

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago