From 2ffe6b8e940f2a1ec80367440e3a5f3960ab6845 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Tue, 18 Feb 2020 20:43:59 +0800 Subject: [PATCH] refactor --- examples/maze/stereographic_hex_maze.scad | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/examples/maze/stereographic_hex_maze.scad b/examples/maze/stereographic_hex_maze.scad index fa47356d..bfe2f143 100644 --- a/examples/maze/stereographic_hex_maze.scad +++ b/examples/maze/stereographic_hex_maze.scad @@ -1,6 +1,7 @@ use ; use ; use ; +use ; x_cells = 10; cell_radius = 20; @@ -10,20 +11,14 @@ shadow = "YES"; // [YES, NO] wall_height = 1; module build_hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness, left_border = true, bottom_border = true) { - // NO_WALL = 0; - // UPPER_WALL = 1; - // RIGHT_WALL = 2; - // UPPER_RIGHT_WALL = 3; + function no_wall(block) = get_wall_type(block) == "NO_WALL"; + function upper_wall(block) = get_wall_type(block) == "UPPER_WALL"; + function right_wall(block) = get_wall_type(block) == "RIGHT_WALL"; + function upper_right_wall(block) = get_wall_type(block) == "UPPER_RIGHT_WALL"; - function no_wall(block) = get_wall_type(block) == 0; - function upper_wall(block) = get_wall_type(block) == 1; - function right_wall(block) = get_wall_type(block) == 2; - function upper_right_wall(block) = get_wall_type(block) == 3; - - function block(x, y, wall_type, visited) = [x, y, wall_type, visited]; - function get_x(block) = block[0]; - function get_y(block) = block[1]; - function get_wall_type(block) = block[2]; + function get_x(block) = mz_get(block, "x"); + function get_y(block) = mz_get(block, "y"); + function get_wall_type(block) = mz_get(block, "w"); function cell_position(x_cell, y_cell) = let(