From c335b4ab828957737b4a88ab05aa6eca5eef99e8 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 29 May 2017 17:43:55 +0800 Subject: [PATCH] refactored --- src/hexagons.scad | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hexagons.scad b/src/hexagons.scad index c2828060..fda1ccc4 100644 --- a/src/hexagons.scad +++ b/src/hexagons.scad @@ -23,13 +23,15 @@ module hexagons(radius, spacing, levels) { rotate(30) circle(r_hexagon, $fn = 6); } + + function offset_xs(n) = + [for(i = [0:n - 1]) i * offset_step + center_offset]; module line_hexagons(n) { - for(i = [0:n - 1]) { - offset_p = [i * offset_step + center_offset, 0, 0]; - translate(offset_p) + for(x = offset_xs(n)) { + translate([x, 0, 0]) hexagon(); - } + } } line_hexagons(beginning_n); @@ -47,4 +49,4 @@ module hexagons(radius, spacing, levels) { line_hexagons(n); } } -} \ No newline at end of file +}