9c9a7b8c67
📊 Benchmark the Runtime / benchmark (pull_request) Successful in 1m7s
🚀 Lint & Test & Deploy / quality (pull_request) Failing after 45s
🚀 Lint & Test & Deploy / test-unit (pull_request) Failing after 30s
🚀 Lint & Test & Deploy / test-e2e (pull_request) Failing after 33s
🚀 Lint & Test & Deploy / deploy (pull_request) Has been skipped
36 lines
805 B
TypeScript
36 lines
805 B
TypeScript
import type { Graph } from '@nodarium/types';
|
|
|
|
export function grid(width: number, height: number) {
|
|
const graph: Graph = {
|
|
id: Math.floor(Math.random() * 100000),
|
|
edges: [],
|
|
nodes: [],
|
|
groups: []
|
|
};
|
|
|
|
const amount = width * height;
|
|
|
|
for (let i = 0; i < amount; i++) {
|
|
const x = i % width;
|
|
const y = Math.floor(i / height);
|
|
|
|
graph.nodes.push({
|
|
id: i,
|
|
position: [x * 30, y * 40],
|
|
props: i == 0 ? { value: 0 } : { op_type: 0, a: 1, b: 0.05 },
|
|
type: i == 0 ? 'max/plantarium/float' : 'max/plantarium/math'
|
|
});
|
|
|
|
graph.edges.push([i, 0, i + 1, i === amount - 1 ? 'input' : 'a']);
|
|
}
|
|
|
|
graph.nodes.push({
|
|
id: amount,
|
|
position: [width * 30, (height - 1) * 40],
|
|
type: 'max/plantarium/output',
|
|
props: {}
|
|
});
|
|
|
|
return graph;
|
|
}
|