Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Aug 25, 2023
1 parent d4b8b8f commit 0dce577
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ await city.generate(params?)
.
## General
#### Get size
```ts
const width = city.width
Expand All @@ -72,6 +73,8 @@ const matrix = city.getMatrix(): MatrixTile[][]
const tile = city.getAt(position: Position): MatrixTile | null
```
.
## Nodes
#### Get all nodes
Expand All @@ -97,7 +100,10 @@ Get type by count of input and output paths (Turn, Cross, End)
const type = node.getType(): NodeType
```
.
## Paths
#### Get all paths
```ts
const paths = city.getAllPaths(): Path[]
Expand Down Expand Up @@ -138,7 +144,10 @@ Get direction in degrees
const direction: number = path.direction
```
.
## Buildings
#### Get all buildings
```ts
const buildings = city.getAllBuildings(): Building[]
Expand Down Expand Up @@ -167,14 +176,20 @@ const width: number = building.width
const height: number = building.height
```
.
## Example
```ts
const city = new City({
width: 200,
height: 200,
});

city.generate().then(() => {
city.generate({
streetMinLength: 15,
}).then(() => {
// Draw roads
ctx.beginPath();
city.getAllPaths().forEach((path) => {
const positions = path.getPositions();
Expand All @@ -183,6 +198,7 @@ city.generate().then(() => {
});
ctx.stroke();

// Draw buildings
city.getAllBuildings().forEach((building) => {
ctx.fillRect(
building.position.x,
Expand Down

0 comments on commit 0dce577

Please sign in to comment.