Merge pull request #66 from rsheldiii/auto-place

Add slightly disappointing auto-placement functionality
This commit is contained in:
Bob 2020-09-30 17:34:15 -04:00 committed by GitHub
commit a3f1d605c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -956,6 +956,19 @@ module debug() {
%children(); %children();
} }
// auto-place children in a grid.
// For this to work all children have to be single keys, no for loops etc
module auto_place() {
num_children = $children;
row_size = round(pow(num_children, 0.5));
for (child_index = [0:num_children-1]) {
x = child_index % row_size;
y = floor(child_index / row_size);
translate_u(x,-y) children(child_index);
}
}
module arrows(profile, rows = [4,4,4,3]) { module arrows(profile, rows = [4,4,4,3]) {
positions = [[0, 0], [1, 0], [2, 0], [1, 1]]; positions = [[0, 0], [1, 0], [2, 0], [1, 1]];
legends = ["←", "↓", "→", "↑"]; legends = ["←", "↓", "→", "↑"];

View File

@ -204,3 +204,16 @@ module debug() {
%children(); %children();
} }
// auto-place children in a grid.
// For this to work all children have to be single keys, no for loops etc
module auto_place() {
num_children = $children;
row_size = round(pow(num_children, 0.5));
for (child_index = [0:num_children-1]) {
x = child_index % row_size;
y = floor(child_index / row_size);
translate_u(x,-y) children(child_index);
}
}