Skip to content

Commit 0523ede

Browse files
docs: add example usage for VectorJS in README
1 parent 1901857 commit 0523ede

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

README.MD

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# VectorJS
2+
3+
## Example
4+
```js
5+
import {Application, Rectangle, Vector2, Palette } from "vectorjs";
6+
7+
const screenWidth = 800;
8+
const screenHeight = 600;
9+
const fpsPos = new Vector2(10, 10);
10+
const rect = new Rectangle(30, 30, 200, 45);
11+
const point1 = new Vector2(400, 150);
12+
const point2 = new Vector2(300, 350);
13+
const point3 = new Vector2(500, 350);
14+
15+
const app = new Application(screenHeight, screenWidth, "Window");
16+
app.run({
17+
18+
onDraw(render) {
19+
render.withLayer2D((ctx) => {
20+
ctx.drawFPS(fpsPos);
21+
22+
ctx.shapes.drawRectangle(rect, {
23+
color: Palette.RED
24+
})
25+
26+
ctx.shapes.drawCircle(point1, 60, {
27+
color: Palette.GREEN
28+
})
29+
30+
ctx.shapes.drawTriangle(point1, point2, point3, {
31+
color: Palette.BLUE
32+
})
33+
34+
});
35+
}
36+
});
37+
```

0 commit comments

Comments
 (0)