From 79c6303db60d71db4fee82a0ea4e2df583321ccb Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 15 Jan 2021 19:25:00 +0800 Subject: [PATCH] refactor --- examples/tube_box.scad | 55 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/examples/tube_box.scad b/examples/tube_box.scad index 36777a1c..ee21a6e6 100644 --- a/examples/tube_box.scad +++ b/examples/tube_box.scad @@ -3,9 +3,39 @@ use ; rows = 8; columns = 15; tile_width = 10; -tile_thickness = 2; $fn = 12; +tube_box(rows, columns, tile_width); + +module tube_box(rows, columns, tile_width) { + half_w = tile_width / 2; + quarter_w = tile_width / 4; + eighth_w = tile_width / 8; + + two_edge_wang_tiles(rows, columns, tile_width) { + tube_tile(0, tile_width); + tube_tile(1, tile_width); + tube_tile(2, tile_width); + tube_tile(3, tile_width); + tube_tile(4, tile_width); + tube_tile(5, tile_width); + tube_tile(6, tile_width); + tube_tile(7, tile_width); + tube_tile(8, tile_width); + tube_tile(9, tile_width); + tube_tile(10, tile_width); + tube_tile(11, tile_width); + tube_tile(12, tile_width); + tube_tile(13, tile_width); + tube_tile(14, tile_width); + tube_tile(15, tile_width); + } + + translate([-half_w - eighth_w, -half_w - eighth_w, -eighth_w]) + box_extrude(height = tile_width, shell_thickness = eighth_w) + square([columns * tile_width + quarter_w, rows * tile_width + quarter_w]); +} + module two_edge_wang_tiles(rows, columns, tile_width) { edges = [ for(y = [0:rows]) @@ -27,29 +57,6 @@ module two_edge_wang_tiles(rows, columns, tile_width) { } } -two_edge_wang_tiles(rows, columns, tile_width) { - tube_tile(0, tile_width); - tube_tile(1, tile_width); - tube_tile(2, tile_width); - tube_tile(3, tile_width); - tube_tile(4, tile_width); - tube_tile(5, tile_width); - tube_tile(6, tile_width); - tube_tile(7, tile_width); - tube_tile(8, tile_width); - tube_tile(9, tile_width); - tube_tile(10, tile_width); - tube_tile(11, tile_width); - tube_tile(12, tile_width); - tube_tile(13, tile_width); - tube_tile(14, tile_width); - tube_tile(15, tile_width); -} - -translate([-tile_width / 2 - tile_width / 8, -tile_width / 2 - tile_width / 8, -tile_width / 8]) -box_extrude(height = tile_width, shell_thickness = tile_width / 8) -square([columns * tile_width + tile_width / 4, rows * tile_width + tile_width / 4]); - module tube_tile(n, width) { half_w = width / 2; quarter_w = width / 4;