From e04381bdeaf6045dc416fb0ac4497a72fa85cc52 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 28 Feb 2022 11:22:58 +0800 Subject: [PATCH] use [each lt, v] to replace concat(lt, [v]) --- examples/hollow_out/hollow_torus_knot.scad | 2 +- examples/maze/torus_knot_maze.scad | 4 +- examples/spiral/vx_spiral_text.scad | 6 +-- examples/spiral_polygons/spiral_polygons.scad | 2 +- .../spiral_polygons/square_pursuit_3d.scad | 4 +- examples/tiles/tiled_line_ring.scad | 40 +++++++++---------- examples/turtle/hilbert_curve_drawing.scad | 6 +-- examples/voronoi/voronoi_melon.scad | 2 +- examples/voronoi/voronoi_sphere.scad | 2 +- examples/voronoi/voronoi_vase.scad | 8 +++- 10 files changed, 36 insertions(+), 40 deletions(-) diff --git a/examples/hollow_out/hollow_torus_knot.scad b/examples/hollow_out/hollow_torus_knot.scad index 86998075..be032c06 100644 --- a/examples/hollow_out/hollow_torus_knot.scad +++ b/examples/hollow_out/hollow_torus_knot.scad @@ -41,7 +41,7 @@ module hollow_out_torus_knot(shape, p, q, phi_step, thickness, line_style) { [0, 90 - a[0], a[1]] ] ) - cross_sections(shape, path, concat([angles[0]], angles)); + cross_sections(shape, path, [angles[0], each angles]); pts = torus_knot(p, q, phi_step); sects = sects_by_path(shape, pts); diff --git a/examples/maze/torus_knot_maze.scad b/examples/maze/torus_knot_maze.scad index b11f1a46..d495575c 100644 --- a/examples/maze/torus_knot_maze.scad +++ b/examples/maze/torus_knot_maze.scad @@ -21,7 +21,7 @@ module torus_knot_maze() { cell_width = 1; torus_knot_path = torus_knot(p, q, phi_step) * rows; columns = len(torus_knot_path); - path = concat(torus_knot_path, [torus_knot_path[0]]); + path = [each torus_knot_path, torus_knot_path[0]]; angle_yz_path = [ for(i = [0:len(path) - 2]) @@ -34,7 +34,7 @@ module torus_knot_maze() { [90 - phi, theta] ]; - angle_yz = concat(angle_yz_path, [angle_yz_path[0]]); + angle_yz = [each angle_yz_path, angle_yz_path[0]]; walls = mz_square_walls( mz_square_cells(rows, columns, x_wrapping = true), diff --git a/examples/spiral/vx_spiral_text.scad b/examples/spiral/vx_spiral_text.scad index 72d80984..88272aff 100644 --- a/examples/spiral/vx_spiral_text.scad +++ b/examples/spiral/vx_spiral_text.scad @@ -55,7 +55,5 @@ function _px_spiral(from, leng, max_leng, clockwise, dir) = leng > max_leng ? [] : _px_spiral_go_turn(from, leng, max_leng, clockwise, dir); function px_spiral(init_leng, max_leng, clockwise = false) = - let( - org = [0, 0] - ) - concat([org], _px_spiral(org, init_leng, max_leng, clockwise, 0)); + let(org = [0, 0]) + [org, each _px_spiral(org, init_leng, max_leng, clockwise, 0)]; diff --git a/examples/spiral_polygons/spiral_polygons.scad b/examples/spiral_polygons/spiral_polygons.scad index 6b265df3..1ebaf0f9 100644 --- a/examples/spiral_polygons/spiral_polygons.scad +++ b/examples/spiral_polygons/spiral_polygons.scad @@ -24,7 +24,7 @@ module spiral_polygons(beginning_radius, line_width, fn, n) { module drawPolygon(r) { pts = shape_circle(radius = r, $fn = fn); - polyline_join(concat(pts, [pts[0]])) + polyline_join([each pts, pts[0]]) circle(half_line_width, $fn = 12); } diff --git a/examples/spiral_polygons/square_pursuit_3d.scad b/examples/spiral_polygons/square_pursuit_3d.scad index 9912a7dd..273ba24b 100644 --- a/examples/spiral_polygons/square_pursuit_3d.scad +++ b/examples/spiral_polygons/square_pursuit_3d.scad @@ -22,7 +22,7 @@ module square_pursuit_3d(length, diff_scale, diameter, n) { npts = [for(i = [0:3]) inter_p(pts[i], pts[(i + 1) % 4], leng, d)]; - polyline_join(concat(npts, [npts[3], npts[0]])) + polyline_join([each npts, npts[3], npts[0]]) sphere(d = diameter); _square_pursuit_3d(npts, diff_scale, diameter, n - 1); @@ -37,7 +37,7 @@ module square_pursuit_3d(length, diff_scale, diameter, n) { [0, length, 0] ]; - polyline_join(concat(pts, [pts[3], pts[0]])) + polyline_join([each pts, pts[3], pts[0]]) sphere(d = diameter); _square_pursuit_3d(pts, diff_scale, diameter, n - 1); diff --git a/examples/tiles/tiled_line_ring.scad b/examples/tiles/tiled_line_ring.scad index 1458476a..eedd4d09 100644 --- a/examples/tiles/tiled_line_ring.scad +++ b/examples/tiles/tiled_line_ring.scad @@ -1,5 +1,6 @@ use ; use ; +use ; radius = 15; height = 10; @@ -12,28 +13,23 @@ module tiled_line_ring(radius, height, line_diameter) { round(2 * radius * PI / line_diameter), round(height / line_diameter) ]; - lines = concat( - [ - for(tile = tile_truchet(size)) - let( - x = tile[0], - y = tile[1], - i = tile[2] - ) - i <= 1 ? - [ - [x * half_line_diameter, y * line_diameter], - [(x + 1) * half_line_diameter, (y + 1) * line_diameter] - ] - : - [ - [(x + 1) * half_line_diameter, y * line_diameter], - [x * half_line_diameter, (y + 1) * line_diameter] - ] - ] - ); + lines = [ + for(tile = tile_truchet(size)) + let( + x = tile[0], + y = tile[1], + i = tile[2] + ) + if(i <= 1) [ + [x * half_line_diameter, y * line_diameter], + [(x + 1) * half_line_diameter, (y + 1) * line_diameter] + ] + else [ + [(x + 1) * half_line_diameter, y * line_diameter], + [x * half_line_diameter, (y + 1) * line_diameter] + ] + ]; - a = 360 / size[0]; for(line = lines) { pts = [ @@ -41,7 +37,7 @@ module tiled_line_ring(radius, height, line_diameter) { [radius * cos(a * p[0]), radius * sin(a * p[0]), p[1]] ]; polyline_join(pts) - sphere(half_line_diameter); + icosahedron(half_line_diameter); } } diff --git a/examples/turtle/hilbert_curve_drawing.scad b/examples/turtle/hilbert_curve_drawing.scad index e9dfeae3..99bf6d3f 100644 --- a/examples/turtle/hilbert_curve_drawing.scad +++ b/examples/turtle/hilbert_curve_drawing.scad @@ -7,11 +7,7 @@ diameter = 0.3; corner_r = 0.5; lines = hilbert_curve(); -hilbert_path = dedup( - concat( - [for(line = lines) line[0]], - [lines[len(lines) - 1][1]]) - ); +hilbert_path = dedup([each [for(line = lines) line[0]], lines[len(lines) - 1][1]]); smoothed_hilbert_path = bezier_smooth(hilbert_path, corner_r); polyline_join(smoothed_hilbert_path) diff --git a/examples/voronoi/voronoi_melon.scad b/examples/voronoi/voronoi_melon.scad index 7f48ba01..5b15c3c5 100644 --- a/examples/voronoi/voronoi_melon.scad +++ b/examples/voronoi/voronoi_melon.scad @@ -14,7 +14,7 @@ module voronoi_melon(eyelets, radius) { color("DarkKhaki") for(cell = cells) { - polyline_join(concat(cell, [cell[0]])) + polyline_join([each cell, cell[0]]) sphere(radius / 60, $fn = 4); } diff --git a/examples/voronoi/voronoi_sphere.scad b/examples/voronoi/voronoi_sphere.scad index 36e1e6d4..c90decb9 100644 --- a/examples/voronoi/voronoi_sphere.scad +++ b/examples/voronoi/voronoi_sphere.scad @@ -60,7 +60,7 @@ module voronoi_sphere(pts, region_hollow, region_offset, region_height) { } - polyline_join(concat(cell, [cell[0]])) + polyline_join([each cell, cell[0]]) sphere(region_offset / 2, $fn = 5); } } \ No newline at end of file diff --git a/examples/voronoi/voronoi_vase.scad b/examples/voronoi/voronoi_vase.scad index 712658a9..d102580a 100644 --- a/examples/voronoi/voronoi_vase.scad +++ b/examples/voronoi/voronoi_vase.scad @@ -50,7 +50,13 @@ module voronoi_vase(r, h, thickness, num_of_pts, fn, profile_step) { intersection() { sweep(sections); render() - vrn3_from(concat([for(i = indices) pts[i]], [sections[0][0], sections[0][half_fn], sections[last_section_i][0], sections[last_section_i][half_fn]])); + vrn3_from([ + each [for(i = indices) pts[i]], + sections[0][0], + sections[0][half_fn], + sections[last_section_i][0], + sections[last_section_i][half_fn] + ]); } }