initial svg

This commit is contained in:
Ari Sosnovsky committed 2021-11-08 15:21:39 -05:00
1 parent c933589998
commit a8c83afaff
22 files changed
+452 -21

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { GRAPH_HEIGHT, GRAPH_WIDTH, NODE_HEIGHT, NODE_WIDTH } from "./constants";
import {DAG, Point} from "./types";
export const clip = (p: Point) : Point => {
const [x,y] = p.map(c => Math.max(0, c));
return [Math.min(GRAPH_WIDTH-NODE_WIDTH, x), Math.min(GRAPH_HEIGHT-NODE_HEIGHT, y)]
}
export interface NormalizedDag extends DAG {
// overflow: boolean;
}
export const normalizeDAG = (dag: DAG): NormalizedDag => {
// let overflow: bo
const nodes = dag.nodes.map(n => ({
...n,
loc: clip(n.loc),
}));
// dag.edges.forEach(edge => {
// const n1 = nodes[edge.from];
// const n2 = nodes[edge.to];
// n2.loc[0] = Math.max(n2.loc[0], n1.loc[0] + 1.25*NODE_WIDTH)
// })
return {
nodes,
edges: dag.edges,
}
}