Simple 2d graphics engine based on drawing vectors.
Written in TypeScript.
Every object update is synchronized with the screen refresh rate.
git clone https://github.com/jodua/2d-vector-graphics-engine.git
cd 2d-vector-graphics-engine
yarn install
yarn build && yarn startCreate endigne with custom renderer settings:
const rendererSettings = {
width: 100,
height: 40,
center: new Point("center", 1, 0, 0),
fps: 60,
outputType: "stdout",
output: process.stdout,
};
const engine = new Engine(rendererSettings);Center point contains coordinates of the center of the screen.
Currently only stdout output is supported.
Add objects to the engine:
const v1 = new Vector(
`vector-name`,
1,
new Point("A", 1, 2, 3),
new Point("B", 2, 7, 10),
5
),
engine.getScene().addEntity(v1);engine.start();In order to add object animation use:
const rotation = new Rotation(
`rotation-animation`,
2,
v1,
new Point("center", 1, 0, 0),
Math.PI / 8,
)
engine.getScene().addAnimation(cubeRotate);
engine.getScene().startAllAnimations();In order to create custom objects you need to create class that extends Entity class.
More about Entity class.
In order to create custom animations you need to create class that extends Animation class.
More about Animation class.
Fill issues through issues tab on github.
MIT license