Show package name in overview

This commit is contained in:
Dennis Schoepf 2021-07-21 16:08:39 +02:00
parent 9790361f24
commit 40d4a2364e
3 changed files with 22 additions and 14 deletions

View file

@ -1,14 +1,14 @@
{ {
"subprojects": [ "subprojects": [
{ {
"name": "sample", "name": "block",
"path": "packages/sample", "path": "packages/block",
"size": 2450, "size": 2450,
"contents": {} "contents": {}
}, },
{ {
"name": "sample", "name": "client",
"path": "packages/sample", "path": "packages/client",
"size": 5600, "size": 5600,
"contents": {} "contents": {}
} }

View file

@ -30,8 +30,9 @@ export function isColliding(
); );
} }
export function generateEdgeCoords(existingCoordinates: Coordinates[]): Coordinates { export function generateEdgeCoords(existingEdges: Edge[]): Coordinates {
let newCoords: Coordinates; let newCoords: Coordinates;
const existingCoordinates = existingEdges.map(({ x, y }) => ({ x, y }));
do { do {
newCoords = generateRandomEdgeCoordinates(); newCoords = generateRandomEdgeCoordinates();
@ -41,23 +42,25 @@ export function generateEdgeCoords(existingCoordinates: Coordinates[]): Coordina
} }
export function generateEdges(subprojects: SubProject[]): Edge[] { export function generateEdges(subprojects: SubProject[]): Edge[] {
let edgeCoords = []; let edges = [];
subprojects.forEach((subproject) => { subprojects.forEach((subproject) => {
const coordinates = generateEdgeCoords(edgeCoords); const coordinates = generateEdgeCoords(edges);
edgeCoords.push({ edges.push({
x: coordinates.x, x: coordinates.x,
y: coordinates.y, y: coordinates.y,
r: getEdgeDimensions(subproject), r: getEdgeDimensions(subproject),
name: subproject.name,
}); });
}); });
return edgeCoords.map( return edges.map(
(edgeCoord) => (edge) =>
new Edge({ new Edge({
x: edgeCoord.x, x: edge.x,
y: edgeCoord.y, y: edge.y,
r: edgeCoord.r, r: edge.r,
name: edge.name,
}) })
); );
} }

View file

@ -5,15 +5,20 @@ export class Edge {
x: number; x: number;
y: number; y: number;
r: number; r: number;
name: string;
constructor({ x, y, r }: { x: number; y: number; r: number }) { constructor({ x, y, r, name }: { x: number; y: number; r: number; name: string }) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.r = r; this.r = r;
this.name = name;
} }
draw() { draw() {
mp5.fill(mp5.color(colors.grey)); mp5.fill(mp5.color(colors.grey));
mp5.ellipse(this.x, this.y, this.r * 2); mp5.ellipse(this.x, this.y, this.r * 2);
mp5.textSize(20);
mp5.fill(0);
mp5.text(this.name, this.x, this.y);
} }
} }