From e4ac6dcb981b48c8e3d02a26264d6904e17fbf56 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 26 Sep 2019 08:53:47 +0800 Subject: [PATCH] format --- examples/bearing_captured_in_mobius_cut.scad | 8 +- examples/chrome_dino.scad | 128 +++++++------- examples/floor_stand/floor_stand.scad | 82 ++++----- examples/floor_stand/floor_stand_text.scad | 20 +-- examples/heart_chain.scad | 36 ++-- examples/hypnotic_squares.scad | 4 +- examples/klein_bottle.scad | 12 +- examples/maze/cylinder_maze.scad | 9 +- examples/maze/pyramid_maze.scad | 15 +- examples/maze/step_pyramid_maze.scad | 34 ++-- examples/maze/stereographic_hex_maze.scad | 8 +- examples/maze/stereographic_square_maze.scad | 4 +- examples/melted_clock.scad | 32 ++-- examples/multiplication_puzzle..scad | 9 +- examples/packing_circles.scad | 14 +- examples/pixel_vase.scad | 14 +- examples/px_spiral_text.scad | 3 +- examples/qr_coder.scad | 34 ++-- examples/spring_dog.scad | 160 +++++++++--------- examples/stick_tower.scad | 8 +- examples/string_tetrahedron.scad | 35 ++-- examples/superformula_vase.scad | 4 +- examples/taiwan/cargo_container_landmark.scad | 54 +++--- examples/taiwan/dancing_taiwan.scad | 6 +- examples/taiwan/leopard_cat_taiwan.scad | 5 +- examples/taiwan/spiral_cube.scad | 38 +++-- examples/text_box.scad | 16 +- examples/text_sphere.scad | 18 +- examples/text_tower.scad | 21 +-- .../triangle2square/triangle2square_box.scad | 9 +- .../triangle2square_pendant.scad | 4 +- examples/twist_bottle.scad | 39 ++--- examples/vampire_pen_holder.scad | 29 ++-- examples/voronoi_vase.scad | 9 +- examples/walk_torus83_fort.scad | 35 ++-- 35 files changed, 500 insertions(+), 456 deletions(-) diff --git a/examples/bearing_captured_in_mobius_cut.scad b/examples/bearing_captured_in_mobius_cut.scad index 3c681682..15625b41 100644 --- a/examples/bearing_captured_in_mobius_cut.scad +++ b/examples/bearing_captured_in_mobius_cut.scad @@ -20,10 +20,14 @@ module bearing_captured_in_mobius_cut(ball_radius, mobius_radius, ring_radius, s circle_points = [for(p = circle_path(ball_track_radius)) p + trans_pt]; difference() { - rotate_extrude() translate([ring_radius, 0, 0]) circle(mobius_radius); + rotate_extrude() + translate([ring_radius, 0, 0]) + circle(mobius_radius); + ring_extrude(circle_points, radius = ring_radius, twist = 180); + rotate([180, 0, 0]) - ring_extrude(circle_points, radius = ring_radius, twist = 180); + ring_extrude(circle_points, radius = ring_radius, twist = 180); } if(with_ball == "YES") { diff --git a/examples/chrome_dino.scad b/examples/chrome_dino.scad index 83f8e987..2f198e1a 100644 --- a/examples/chrome_dino.scad +++ b/examples/chrome_dino.scad @@ -136,68 +136,73 @@ module blocks(points) { module cactus(w) { linear_extrude(w * 3) { - translate([2 * w, w * 7]) scale(w) blocks( - px_polygon([ - [0, 2], - [3, 2], - [5, 4], - [5, 10], - [5, 10], - [3, 10], - [3, 6], - [0, 4], - - ], filled = true) - ); + translate([2 * w, w * 7]) + scale(w) + blocks( + px_polygon([ + [0, 2], + [3, 2], + [5, 4], + [5, 10], + [5, 10], + [3, 10], + [3, 6], + [0, 4], + + ], filled = true) + ); - translate([-2 * w, w * 5]) scale(w) blocks( - px_polygon([ - [-1, 0], - [-3, 0], - [-6, 2], - [-6, 6], - [-6, 6], - [-4, 6], - [-4, 4], - [-1, 2], - - ], filled = true) - ); + translate([-2 * w, w * 5]) + scale(w) + blocks( + px_polygon([ + [-1, 0], + [-3, 0], + [-6, 2], + [-6, 6], + [-6, 6], + [-4, 6], + [-4, 4], + [-1, 2], + + ], filled = true) + ); - scale(w) blocks( - px_polygon([ - [-2, 0], - [2, 0], - [2, 20], - [1, 22], - [0, 22], - [-1, 22], - [-2, 20] - ], filled = true) - ); + scale(w) + blocks( + px_polygon([ + [-2, 0], + [2, 0], + [2, 20], + [1, 22], + [0, 22], + [-1, 22], + [-2, 20] + ], filled = true) + ); } } module base(w, base_x_blocks, base_y_blocks) { linear_extrude(w) { - translate([0, -w]) - square([base_x_blocks * w, base_y_blocks * w + 2 * w]); - translate([0, base_y_blocks * w / 2]) scale(w) blocks( - px_circle(base_y_blocks / 2, filled = true) - ); + translate([0, -w]) + square([base_x_blocks * w, base_y_blocks * w + 2 * w]); - translate([base_x_blocks * w, base_y_blocks * w / 2]) - scale(w) blocks( - px_circle(base_y_blocks / 2, filled = true) - ); + translate([0, base_y_blocks * w / 2]) + scale(w) + blocks(px_circle(base_y_blocks / 2, filled = true)); + + translate([base_x_blocks * w, base_y_blocks * w / 2]) + scale(w) + blocks(px_circle(base_y_blocks / 2, filled = true)); } } module eye(w, eye_spacing) { translate([0, 0, -eye_spacing]) - rotate([0, -90, 0]) - linear_extrude(w * 5) - offset(delta = -eye_spacing) square(w); + rotate([0, -90, 0]) + linear_extrude(w * 5) + offset(delta = -eye_spacing) square(w); } if(part == "DINO") { @@ -214,28 +219,35 @@ else if(part == "BASE") { } else if(part == "DEMO") { wd = 5; - translate([0, wd * 5.5, wd * 5]) rotate([90, 0, 0]) { + translate([0, wd * 5.5, wd * 5]) + rotate([90, 0, 0]) { color("DimGray") chrome_dino(wd, true); color("white") - linear_extrude(wd * 5) - translate([7 * wd, 14 * wd]) square(wd, center = true); + linear_extrude(wd * 5) + translate([7 * wd, 14 * wd]) square(wd, center = true); } color("white") base(wd, 10, 6); translate([wd * 25, wd * 10, 0]) { - translate([wd * 4.25, wd * 4.25, 0]) color("SlateGray") rotate([90, 0, 0]) + translate([wd * 4.25, wd * 4.25, 0]) + color("SlateGray") + rotate([90, 0, 0]) cactus(wd); + color("white") base(wd, 10, 6); } translate([-wd * 35, wd * 10, 0]) { color("SlateGray") { - translate([wd * 4.25, wd * 4, 0]) rotate([90, 0, 0]) - mirror([1, 0, 0]) cactus(wd); + translate([wd * 4.25, wd * 4, 0]) + rotate([90, 0, 0]) + mirror([1, 0, 0]) + cactus(wd); - scale(0.75) - translate([wd * 30, wd * 5, 0]) rotate([90, 0, 0]) - cactus(wd); + scale(0.75) + translate([wd * 30, wd * 5, 0]) + rotate([90, 0, 0]) + cactus(wd); } color("white") base(wd, 30, 6); } diff --git a/examples/floor_stand/floor_stand.scad b/examples/floor_stand/floor_stand.scad index 18762fa7..e42fcd59 100644 --- a/examples/floor_stand/floor_stand.scad +++ b/examples/floor_stand/floor_stand.scad @@ -14,12 +14,13 @@ module floor_stand(width, height, thickness, spacing) { module board_base() { translate([0, -half_h, 0]) - difference() { + difference() { + polygon(points); + + translate([0, -half_h, 0]) + scale([0.6, 0.1]) polygon(points); - translate([0, -half_h, 0]) - scale([0.6, 0.1]) - polygon(points); - } + } } module board_U() { @@ -27,13 +28,13 @@ module floor_stand(width, height, thickness, spacing) { difference() { union() { linear_extrude(thickness, center = true) - difference() { - board_base(); - square([width / 1.5, height / 3], center = true); - } + difference() { + board_base(); + square([width / 1.5, height / 3], center = true); + } rotate(angles) - linear_extrude(width / 2.25 * 2, center = true) - circle(half_th); + linear_extrude(width / 2.25 * 2, center = true) + circle(half_th); } rotate(angles) { @@ -52,11 +53,12 @@ module floor_stand(width, height, thickness, spacing) { board_base(); square([width, height / 3], center = true); } + translate([0, -height / 12 - spacing / 2, 0]) - difference() { - square([width / 1.5 - double_spacing, height / 6 + spacing], center = true); - square([width / 1.5 - thickness * 2, height / 6], center = true); - } + difference() { + square([width / 1.5 - double_spacing, height / 6 + spacing], center = true); + square([width / 1.5 - thickness * 2, height / 6], center = true); + } } rotate([0, 90, 0]) { @@ -68,11 +70,12 @@ module floor_stand(width, height, thickness, spacing) { module border() { translate([0, 0, half_th]) - color("black") linear_extrude(half_th / 2) - hollow_out(shell_thickness = font_size / 4) - offset(half_w / 10) - scale([0.75, 0.675]) - polygon(points); + color("black") + linear_extrude(half_th / 2) + hollow_out(shell_thickness = font_size / 4) + offset(half_w / 10) + scale([0.75, 0.675]) + polygon(points); } module stick() { @@ -82,36 +85,35 @@ module floor_stand(width, height, thickness, spacing) { module decorate() { rotate([-80, 0, 0]) + difference() { + rotate([80, 0, 0]) difference() { - rotate([80, 0, 0]) - difference() { - union() { - color("yellow") children(); - translate([0, -height / 1.8, 0]) - border(); - } - // slot - translate([0, -half_h - thickness, -half_th]) - stick(); - } - - translate([0, 0, -height - half_th]) - linear_extrude(thickness) - square(width, center = true); + union() { + color("yellow") children(); + translate([0, -height / 1.8, 0]) border(); + } + // slot + translate([0, -half_h - thickness, -half_th]) + stick(); } + + translate([0, 0, -height - half_th]) + linear_extrude(thickness) + square(width, center = true); + } } // stick translate([width, 0, 0]) stick(); translate([0, 0, half_th]) - decorate() - board_U(); + decorate() + board_U(); translate([0, 0, half_th]) - rotate(180) - decorate() - board_T(); + rotate(180) + decorate() + board_T(); children(0); if($children == 1) { diff --git a/examples/floor_stand/floor_stand_text.scad b/examples/floor_stand/floor_stand_text.scad index b1443d74..832e767b 100644 --- a/examples/floor_stand/floor_stand_text.scad +++ b/examples/floor_stand/floor_stand_text.scad @@ -20,16 +20,16 @@ module words(text, font, font_size, height, thickness, line_spacing) { color("black") translate([0, -height / 1.8, thickness]) - linear_extrude(half_th / 2) { - multi_line_text( - split_str(text, " "), - font = font, - size = font_size, - line_spacing = line_spacing, - valign = "center", - halign = "center" - ); - } + linear_extrude(half_th / 2) { + multi_line_text( + split_str(text, " "), + font = font, + size = font_size, + line_spacing = line_spacing, + valign = "center", + halign = "center" + ); + } } floor_stand(stand_width, stand_height, stand_thickness, stand_spacing) diff --git a/examples/heart_chain.scad b/examples/heart_chain.scad index 5e1a93bd..002b2713 100644 --- a/examples/heart_chain.scad +++ b/examples/heart_chain.scad @@ -10,11 +10,11 @@ module heart(radius, center = false) { module heart_sub_component() { translate([-radius * cos(rotated_angle), 0, 0]) - rotate(-rotated_angle) union() { - circle(radius); - translate([0, -radius, 0]) - square(diameter); - } + rotate(-rotated_angle) union() { + circle(radius); + translate([0, -radius, 0]) + square(diameter); + } } offsetX = center ? 0 : radius + radius * cos(45); @@ -33,8 +33,8 @@ module heart_with_ears(heart_width, thickness, spacing) { arc(radius, [0, 240], width, "LINE_OUTWARD"); translate([0, 0, thickness + spacing]) - linear_extrude(thickness) - arc(radius, [240, 360], width, "LINE_OUTWARD"); + linear_extrude(thickness) + arc(radius, [240, 360], width, "LINE_OUTWARD"); linear_extrude(thickness * 2 + spacing) arc(radius, [0, 20], width, "LINE_OUTWARD"); @@ -50,12 +50,12 @@ module heart_with_ears(heart_width, thickness, spacing) { heart(heart_radius, center = true); translate([ring_x, ring_y, 0]) - rotate(-40) - ear(ring_radius, ring_thickness, spacing); + rotate(-40) + ear(ring_radius, ring_thickness, spacing); translate([-ring_x, ring_y, 0]) - rotate(125) - ear(ring_radius, ring_thickness, spacing); + rotate(125) + ear(ring_radius, ring_thickness, spacing); } module text_heart(char, width, thickness, spacing) { @@ -64,13 +64,13 @@ module text_heart(char, width, thickness, spacing) { difference() { heart_with_ears(width, thickness, spacing); translate([0, 0, half_thickness]) - linear_extrude(half_thickness) - offset(-half_thickness) - heart(radius, center = true); + linear_extrude(half_thickness) + offset(-half_thickness) + heart(radius, center = true); } translate([0, radius / 4, half_thickness]) - linear_extrude(half_thickness) - text(char, font = "Arial Black", size = radius * 1.2, valign = "center", halign="center"); + linear_extrude(half_thickness) + text(char, font = "Arial Black", size = radius * 1.2, valign = "center", halign="center"); } module heart_chain(chars) { @@ -91,8 +91,8 @@ module heart_chain(chars) { pt = points_angles[i][0]; angle = points_angles[i][1]; translate(pt) - rotate(angle + 90) - text_heart(chars[i], heart_width, heart_thickness, spacing); + rotate(angle + 90) + text_heart(chars[i], heart_width, heart_thickness, spacing); } } diff --git a/examples/hypnotic_squares.scad b/examples/hypnotic_squares.scad index 92fb1eff..a149d8ca 100644 --- a/examples/hypnotic_squares.scad +++ b/examples/hypnotic_squares.scad @@ -19,8 +19,8 @@ module hypnotic_squares(x_grids, y_grids, grid_size, final_size, line_width) { module hollow_square(x, y, size) { translate([x - half_lw, y - half_lw]) - hollow_out(line_width) - square(size + line_width); + hollow_out(line_width) + square(size + line_width); } module draw(x, y, size, xMovement, yMovement, steps) { diff --git a/examples/klein_bottle.scad b/examples/klein_bottle.scad index 31d2cfaf..57c7f1e8 100644 --- a/examples/klein_bottle.scad +++ b/examples/klein_bottle.scad @@ -17,11 +17,11 @@ cut = false; // [true,false] module klein_bottle(radius1, radius2, bottom_height, thickness, t_step, fn) { $fn = fn; + half_thickness = thickness / 2; module bottom() { - rotate(180) rotate_extrude() { - - + rotate(180) + rotate_extrude() { translate([radius1 + radius2, 0, 0]) polyline2d( arc_path(radius = radius2, angle = [180, 360]) @@ -54,7 +54,7 @@ module klein_bottle(radius1, radius2, bottom_height, thickness, t_step, fn) { [0, radius1 * 4, bottom_height], [0, radius1 * 3, bottom_height - radius1], [0, radius1 * 2, bottom_height - radius1 * 2], - [0, radius1, bottom_height + thickness / 2 - radius1 * 3], + [0, radius1, bottom_height + half_thickness - radius1 * 3], [0, 0, bottom_height - radius1 * 4], [0, 0, bottom_height - radius1 * 5] ]; @@ -80,13 +80,13 @@ module klein_bottle(radius1, radius2, bottom_height, thickness, t_step, fn) { bottom(); path_extrude( - circle_path(radius1 + thickness / 2), + circle_path(radius1 + half_thickness), tube_path ); } path_extrude( - circle_path(radius1 - thickness / 2), + circle_path(radius1 - half_thickness), tube_path2 ); } diff --git a/examples/maze/cylinder_maze.scad b/examples/maze/cylinder_maze.scad index b3616f8b..b9a44434 100644 --- a/examples/maze/cylinder_maze.scad +++ b/examples/maze/cylinder_maze.scad @@ -24,11 +24,12 @@ module build_ramp_maze(rows, columns, blocks, block_width, wall_thickness, wall_ hull() { translate(point1) - linear_extrude(height, scale = top_scale) - square(width, center = true); + linear_extrude(height, scale = top_scale) + square(width, center = true); + translate(point2) - linear_extrude(height, scale = top_scale) - square(width, center = true); + linear_extrude(height, scale = top_scale) + square(width, center = true); } } diff --git a/examples/maze/pyramid_maze.scad b/examples/maze/pyramid_maze.scad index c2ac831a..106fcda6 100644 --- a/examples/maze/pyramid_maze.scad +++ b/examples/maze/pyramid_maze.scad @@ -23,13 +23,14 @@ module pyramid_maze(maze_rows, block_width, wall_thickness) { intersection() { linear_extrude(leng * 2) - translate([-half_leng, -half_leng]) build_square_maze( - maze_rows, - maze_rows, - maze_blocks, - block_width, - wall_thickness - ); + translate([-half_leng, -half_leng]) build_square_maze( + maze_rows, + maze_rows, + maze_blocks, + block_width, + wall_thickness + ); + pyramid(leng + wall_thickness); } } diff --git a/examples/maze/step_pyramid_maze.scad b/examples/maze/step_pyramid_maze.scad index 77e64c8c..8c46d317 100644 --- a/examples/maze/step_pyramid_maze.scad +++ b/examples/maze/step_pyramid_maze.scad @@ -20,8 +20,8 @@ module pyramid_with_stairs(base_width, stairs_width, rows) { for(j = [1:stairsteps]) { square_w = base_w - j * staircase_w; translate([0, 0, staircase_h * (j - 1)]) - linear_extrude(staircase_h) - square([square_w, square_w], center = true); + linear_extrude(staircase_h) + square([square_w, square_w], center = true); } } @@ -46,23 +46,23 @@ module step_pyramid_maze(maze_rows, block_width, stairs_width) { square([block_width * maze_rows + stairs_width, block_width * maze_rows + stairs_width], center = true); translate([-(maze_rows * block_width) / 2, -(maze_rows * block_width) / 2, 0]) - difference() { - build_square_maze( - maze_rows, - maze_rows, - maze_blocks, - block_width, - stairs_width - ); + difference() { + build_square_maze( + maze_rows, + maze_rows, + maze_blocks, + block_width, + stairs_width + ); - // entry - translate([0, stairs_width]) - square(stairs_width, center = true); + // entry + translate([0, stairs_width]) + square(stairs_width, center = true); - // exit - translate([maze_rows * block_width, maze_rows * block_width - stairs_width]) - square(stairs_width, center = true); - } + // exit + translate([maze_rows * block_width, maze_rows * block_width - stairs_width]) + square(stairs_width, center = true); + } } } } diff --git a/examples/maze/stereographic_hex_maze.scad b/examples/maze/stereographic_hex_maze.scad index 5276d643..7dd561fd 100644 --- a/examples/maze/stereographic_hex_maze.scad +++ b/examples/maze/stereographic_hex_maze.scad @@ -27,14 +27,14 @@ module hex_maze_stereographic_projection(x_cells, cell_radius, wall_thickness, f maze_vector = go_maze(1, 1, starting_maze(y_cells, x_cells), y_cells, x_cells); stereographic_extrude(square_w, $fn = fn) - translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) - build_hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness); + translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) + build_hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness); if(shadow == "YES") { color("black") linear_extrude(wall_height) - translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) - build_hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness); + translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) + build_hex_maze(y_cells, x_cells, maze_vector, cell_radius, wall_thickness); } } diff --git a/examples/maze/stereographic_square_maze.scad b/examples/maze/stereographic_square_maze.scad index 4834a04e..f43a664b 100644 --- a/examples/maze/stereographic_square_maze.scad +++ b/examples/maze/stereographic_square_maze.scad @@ -34,8 +34,8 @@ module stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn if(shadow == "YES") { color("black") - linear_extrude(wall_height) - maze(); + linear_extrude(wall_height) + maze(); } } diff --git a/examples/melted_clock.scad b/examples/melted_clock.scad index f18adc12..2ae58f74 100644 --- a/examples/melted_clock.scad +++ b/examples/melted_clock.scad @@ -23,7 +23,8 @@ module clock(r, thickness, hour, minute) { line2d([0, 0], [0, r - thickness * 3], thickness * 0.75, p1Style = "CAP_ROUND", p2Style = "CAP_ROUND", $fn = 4); for(i = [0: 11]) { - rotate(i * 30) translate([0, r - thickness * 4, 0]) + rotate(i * 30) + translate([0, r - thickness * 4, 0]) square([thickness / 2, thickness * 2]); } } @@ -34,12 +35,12 @@ module melt(r, thickness, angle, frags, xscale = 1) { rz = r * 180 / (angle * 3.14159); mirror([0, 1, 0]) - scale([xscale, 1, 1]) - translate([0, r, rz]) - rotate([0, 90, -90]) - bend_extrude([r, double_r], thickness, angle, frags) - translate([0, r, 0]) - children(); + scale([xscale, 1, 1]) + translate([0, r, rz]) + rotate([0, 90, -90]) + bend_extrude([r, double_r], thickness, angle, frags) + translate([0, r, 0]) + children(); linear_extrude(thickness) intersection() { @@ -55,15 +56,16 @@ module melted_clock() { $fn = 48; sa = r * angle / (r + thickness); rotate([0, 180, 0]) - mirror([1, 0, 0]) { - color("Gold") - translate([0, 0, thickness]) - melt(r, thickness, angle, frags, xscale) circle(r); - - color("Gainsboro") melt(r, thickness, sa, frags, xscale) + mirror([1, 0, 0]) { + color("Gold") + translate([0, 0, thickness]) + melt(r, thickness, angle, frags, xscale) + circle(r); + + color("Gainsboro") + melt(r, thickness, sa, frags, xscale) clock(r - thickness * 2, thickness, hour, minute); - ; - } + } } melted_clock(); \ No newline at end of file diff --git a/examples/multiplication_puzzle..scad b/examples/multiplication_puzzle..scad index 75d025db..a0fa74f1 100644 --- a/examples/multiplication_puzzle..scad +++ b/examples/multiplication_puzzle..scad @@ -54,9 +54,8 @@ module puzzle_piece_with_text(side_length, text, spacing) { difference() { puzzle_piece(side_length, spacing); translate([half_side_length, half_side_length]) - rotate(-45) - text(text, size = side_length / 3, - halign = "center", valign = "center"); + rotate(-45) + text(text, size = side_length / 3, halign = "center", valign = "center"); } } @@ -95,8 +94,8 @@ module multiplication_puzzle(n, piece_side_length, spacing) { } } linear_extrude(r - 0.6) - translate(pos) - puzzle_piece(piece_side_length, spacing); + translate(pos) + puzzle_piece(piece_side_length, spacing); } } diff --git a/examples/packing_circles.scad b/examples/packing_circles.scad index c888e87e..25d2ee62 100644 --- a/examples/packing_circles.scad +++ b/examples/packing_circles.scad @@ -52,13 +52,15 @@ function packing_circles(size, min_radius, max_radius, total_circles, attempts = circles = packing_circles(size, min_radius, max_radius, total_circles); mr = max([for(c = circles) c[2]]); -translate([0, 0, mr]) for(c = circles) { - translate([c[0], c[1]]) - sphere(c[2], $fn = 48); -} +translate([0, 0, mr]) + for(c = circles) { + translate([c[0], c[1]]) + sphere(c[2], $fn = 48); + } + for(c = circles) { translate([c[0], c[1]]) - linear_extrude(mr) - circle(c[2]/ 3, $fn = 48); + linear_extrude(mr) + circle(c[2]/ 3, $fn = 48); } linear_extrude(1) square(size); diff --git a/examples/pixel_vase.scad b/examples/pixel_vase.scad index 5457ff55..61ecdee5 100644 --- a/examples/pixel_vase.scad +++ b/examples/pixel_vase.scad @@ -23,20 +23,18 @@ module pixel_vase(x1, x2, x3, thickness) { leng = len(px_path); for(p = px_cylinder(px_path[0][0], 1, true)) { - linear_extrude(1) union() { - translate([p[0], p[1]]) - square(1.1, center = true); - } + linear_extrude(1) + translate([p[0], p[1]]) + square(1.1, center = true); } for(i = [0:leng - 1]) { r = px_path[i][0]; for(p = px_cylinder(r, 1, thickness = thickness)) { translate([0, 0, i]) - linear_extrude(1) union() { - translate([p[0], p[1]]) - square(1.1, center = true); - } + linear_extrude(1) + translate([p[0], p[1]]) + square(1.1, center = true); } } } diff --git a/examples/px_spiral_text.scad b/examples/px_spiral_text.scad index 3d05f961..fa5763e7 100644 --- a/examples/px_spiral_text.scad +++ b/examples/px_spiral_text.scad @@ -7,7 +7,8 @@ tx = "3.141592653589793238462643383279502884197169399375105820974944592307816406 pts = [for(p = px_spiral(1, floor(sqrt(len(tx))) + 1)) p * 8]; linear_extrude(2) for(i = [0:len(tx) - 1]) { - translate(pts[i]) difference() { + translate(pts[i]) + difference() { square(7, center = true); render() for(p = px_ascii(tx[i], center = true)) { translate(p) square(.8); diff --git a/examples/qr_coder.scad b/examples/qr_coder.scad index 97ad2427..4cf9f881 100644 --- a/examples/qr_coder.scad +++ b/examples/qr_coder.scad @@ -16,9 +16,10 @@ qr_coder(); module qr_coder() { color("black") rotate([0, 180, 0]) - translate([0, 0, -qr_thickness - head_size]) - linear_extrude(qr_thickness) - mirror([1, 0, 0]) qrcode(t, head_size * 0.9, encoding, min_error_correction_level, mask, center = true); + translate([0, 0, -qr_thickness - head_size]) + linear_extrude(qr_thickness) + mirror([1, 0, 0]) + qrcode(t, head_size * 0.9, encoding, min_error_correction_level, mask, center = true); cube_character(head_size); } @@ -33,8 +34,8 @@ module cube_character(head_size) { square(head_size, center = true); translate([0, -half_head_size, half_head_size]) - rotate([-90, 0, 0]) - connector_peg(peg_radius, spacing = spacing, void = true); + rotate([-90, 0, 0]) + connector_peg(peg_radius, spacing = spacing, void = true); } } @@ -44,25 +45,26 @@ module cube_character(head_size) { module peg_void() { translate([half_body_size + 1, head_size * 0.2, half_body_size]) - rotate([0, -90, 0]) - connector_peg(peg_radius, spacing = spacing, void = true); + rotate([0, -90, 0]) + connector_peg(peg_radius, spacing = spacing, void = true); } difference() { - linear_extrude(body_size) union() { + linear_extrude(body_size) + union() { square(body_size, center = true); // feet translate([0, -head_size * 0.4, 0]) - difference() { - square(head_size * 0.65, center = true); - square([head_size * 0.05, head_size * 0.65], center = true); - } + difference() { + square(head_size * 0.65, center = true); + square([head_size * 0.05, head_size * 0.65], center = true); + } } // holes translate([0, half_body_size + 1, half_body_size]) - rotate([90, 0, 0]) - connector_peg(peg_radius, spacing = spacing, void = true); + rotate([90, 0, 0]) + connector_peg(peg_radius, spacing = spacing, void = true); peg_void(); mirror([1, 0, 0]) peg_void(); @@ -80,8 +82,8 @@ module cube_character(head_size) { square(hand_size, center = true); translate([head_size * 0.1375, head_size * 0.1375, half_body_size / 2]) - rotate([0, 90, 0]) - connector_peg(peg_radius, spacing = spacing); + rotate([0, 90, 0]) + connector_peg(peg_radius, spacing = spacing); } } diff --git a/examples/spring_dog.scad b/examples/spring_dog.scad index e9286a48..77bc366b 100644 --- a/examples/spring_dog.scad +++ b/examples/spring_dog.scad @@ -54,21 +54,24 @@ module dog_back(head_r, peg_radius) { $fn = 36; module foot() { - translate([head_r, 0, 0]) union() { + translate([head_r, 0, 0]) + union() { color("PapayaWhip") - ellipse_extrude(head_r / 3) polygon( - shape_ellipse([head_r / 3, head_r / 2]) - ); + ellipse_extrude(head_r / 3) + polygon(shape_ellipse([head_r / 3, head_r / 2])); color("Maroon") - linear_extrude(head_r) circle(head_r / 8); + linear_extrude(head_r) + circle(head_r / 8); - color("Goldenrod") translate([head_r / 45, 0, head_r / 2]) - rotate([0, -15, 0]) rounded_cylinder( - radius = [head_r / 5, head_r / 3.5], - h = head_r * 1.25, - round_r = 2 - ); + color("Goldenrod") + translate([head_r / 45, 0, head_r / 2]) + rotate([0, -15, 0]) + rounded_cylinder( + radius = [head_r / 5, head_r / 3.5], + h = head_r * 1.25, + round_r = 2 + ); } } @@ -96,16 +99,17 @@ module dog_back(head_r, peg_radius) { body_feet(); rotate([-36.5, 0, 0]) - color("Goldenrod") - linear_extrude(head_r * 2, scale = 0.5) - circle(head_r / 6); + color("Goldenrod") + linear_extrude(head_r * 2, scale = 0.5) + circle(head_r / 6); } back(); - color("Goldenrod") translate([0, -head_r * 0.2, 0]) - rotate([90, 0, 0]) - connector_peg(peg_radius, spacing = spacing); + color("Goldenrod") + translate([0, -head_r * 0.2, 0]) + rotate([90, 0, 0]) + connector_peg(peg_radius, spacing = spacing); } module spring_dog_spring(head_r, spring_levels, line_thickness, line_distance, peg_radius, plate_h, spacing) { @@ -150,45 +154,44 @@ module dog_front(head_r, peg_radius, spacing) { module head() { module head_nose() { color("Goldenrod") - rotate([-15, 0, 0]) - scale([1, 0.9, 0.9]) - sphere(head_r); + rotate([-15, 0, 0]) + scale([1, 0.9, 0.9]) + sphere(head_r); // nose color("PapayaWhip") - translate([0, -head_r * 0.45, -head_r / 5]) - rotate([85, 0, 0]) - scale([1.25, 0.8, 1]) - rounded_cylinder( - radius = [head_r / 2, head_r / 6], - h = head_r * 1.25, - round_r = 4 - ); + translate([0, -head_r * 0.45, -head_r / 5]) + rotate([85, 0, 0]) + scale([1.25, 0.8, 1]) + rounded_cylinder( + radius = [head_r / 2, head_r / 6], + h = head_r * 1.25, + round_r = 4 + ); color("black") - translate([0, -head_r * 1.6, 0]) - rotate([15, 0, 0]) - scale([1.25, 1, 1]) - sphere(head_r / 7); + translate([0, -head_r * 1.6, 0]) + rotate([15, 0, 0]) + scale([1.25, 1, 1]) + sphere(head_r / 7); } module eye() { translate([head_r / 2, -head_r / 1.75, head_r / 3]) - rotate([-20, 5, 30]) - scale([1.2, 0.5, 1]) { - color("Goldenrod") - sphere(head_r / 3); + rotate([-20, 5, 30]) + scale([1.2, 0.5, 1]) { + color("Goldenrod") sphere(head_r / 3); - color("white") - translate([0, 0, -head_r / 15]) - rotate([-25, -10, 0]) - scale([1.1, 1.25, 1.2]) - sphere(head_r / 3.5); - - color("black") - translate([-head_r / 15, -head_r / 4, -head_r / 12]) - sphere(head_r / 7); - } + color("white") + translate([0, 0, -head_r / 15]) + rotate([-25, -10, 0]) + scale([1.1, 1.25, 1.2]) + sphere(head_r / 3.5); + + color("black") + translate([-head_r / 15, -head_r / 4, -head_r / 12]) + sphere(head_r / 7); + } } module eyes() { @@ -199,9 +202,9 @@ module dog_front(head_r, peg_radius, spacing) { module eyebrow() { color("black") translate([head_r / 2.5, -head_r / 2.5, head_r / 3]) - rotate([60, 15, 30]) - linear_extrude(head_r / 2, center = true) scale([1.5, 1, 1]) - arc(radius = head_r / 3, angle = 120, width = head_r / 20); + rotate([60, 15, 30]) + linear_extrude(head_r / 2, center = true) scale([1.5, 1, 1]) + arc(radius = head_r / 3, angle = 120, width = head_r / 20); } @@ -215,18 +218,18 @@ module dog_front(head_r, peg_radius, spacing) { module ear() { color("Maroon") rotate([-15, 0, -10]) - translate([-head_r / 2.75, head_r / 15, -head_r / 2.75]) - rotate([0, -60, 0]) - scale([1.25, 1, 1]) intersection() { - translate([head_r, 0, 0]) - linear_extrude(head_r) - polygon(shape_pts); + translate([-head_r / 2.75, head_r / 15, -head_r / 2.75]) + rotate([0, -60, 0]) + scale([1.25, 1, 1]) intersection() { + translate([head_r, 0, 0]) + linear_extrude(head_r) + polygon(shape_pts); - difference() { - sphere(head_r); - sphere(head_r - head_r / 10); - } - } + difference() { + sphere(head_r); + sphere(head_r - head_r / 10); + } + } } module ears() { @@ -242,21 +245,25 @@ module dog_front(head_r, peg_radius, spacing) { module foot() { - translate([head_r, -head_r / 11, 0]) union() { + translate([head_r, -head_r / 11, 0]) { color("PapayaWhip") - ellipse_extrude(head_r / 3) polygon( - shape_ellipse([head_r / 3, head_r / 2]) - ); + ellipse_extrude(head_r / 3) + polygon( + shape_ellipse([head_r / 3, head_r / 2]) + ); color("Maroon") - linear_extrude(head_r) circle(head_r / 8); + linear_extrude(head_r) + circle(head_r / 8); color("Goldenrod") - translate([head_r / 45, 0, head_r / 2]) rotate([0, -15, 0]) rounded_cylinder( - radius = [head_r / 5, head_r / 3.5], - h = head_r * 1.25, - round_r = 2 - ); + translate([head_r / 45, 0, head_r / 2]) + rotate([0, -15, 0]) + rounded_cylinder( + radius = [head_r / 5, head_r / 3.5], + h = head_r * 1.25, + round_r = 2 + ); } } @@ -271,7 +278,8 @@ module dog_front(head_r, peg_radius, spacing) { feet(); color("Goldenrod") - scale([1, 1.25, 1]) difference() { + scale([1, 1.25, 1]) + difference() { sphere(head_r); translate([-head_r, head_r / 6, -head_r]) @@ -287,13 +295,13 @@ module dog_front(head_r, peg_radius, spacing) { color("Goldenrod") linear_extrude(head_r * 2) circle(head_r / 4); - + color("green") translate([0, 0, head_r * 1.1]) - rotate([-10, 0, 0]) - rotate_extrude() - translate([head_r / 4, 0, 0]) - circle(head_r / 10); + rotate([-10, 0, 0]) + rotate_extrude() + translate([head_r / 4, 0, 0]) + circle(head_r / 10); } } diff --git a/examples/stick_tower.scad b/examples/stick_tower.scad index bd2413c5..543cf903 100644 --- a/examples/stick_tower.scad +++ b/examples/stick_tower.scad @@ -39,8 +39,8 @@ module stick_square(inner_square_leng, stick_leng, stick_thickness, cap_style) { sticks(); translate([0, 0, stick_thickness]) - rotate(90) - sticks(); + rotate(90) + sticks(); } module spiral_stack(orig_leng, orig_height, current_leng, leng_diff, min_leng, angle_offset, pre_height = 0, i = 0) { @@ -50,8 +50,8 @@ module spiral_stack(orig_leng, orig_height, current_leng, leng_diff, min_leng, a factor = current_leng / orig_leng; translate([0, 0, pre_height]) - scale(factor) - children(); + scale(factor) + children(); next_square_leng = sqrt(pow(leng_diff, 2) + pow(current_leng - leng_diff, 2)); diff --git a/examples/string_tetrahedron.scad b/examples/string_tetrahedron.scad index c3fe7a4e..6d360aea 100644 --- a/examples/string_tetrahedron.scad +++ b/examples/string_tetrahedron.scad @@ -61,22 +61,22 @@ module base(leng, thickness, line_fn) { sphere(r, $fn = 48); translate([0, 0, -r]) - linear_extrude(r) - square(r * 2, center = true); + linear_extrude(r) + square(r * 2, center = true); translate([0, 0, height(leng) + half_th]) - rotate([0, 180, 0]) - translate([0, -leng / 2 * tan(30), 0]) - hull() { - translate(vts[0]) - sphere(half_th, $fn = line_fn); - translate(vts[1]) - sphere(half_th, $fn = line_fn); - translate(vts[2]) - sphere(half_th, $fn = line_fn); - translate(vts[3]) - sphere(half_th, $fn = line_fn); - } + rotate([0, 180, 0]) + translate([0, -leng / 2 * tan(30), 0]) + hull() { + translate(vts[0]) + sphere(half_th, $fn = line_fn); + translate(vts[1]) + sphere(half_th, $fn = line_fn); + translate(vts[2]) + sphere(half_th, $fn = line_fn); + translate(vts[3]) + sphere(half_th, $fn = line_fn); + } } } @@ -86,9 +86,10 @@ if(model == "Tetrahedron") { base(leng, thickness, line_fn); } else { translate([0, 0, height(leng) + half_th]) - rotate([0, 180, 0]) - translate([0, -leng / 2 * tan(30), 0]) - string_tetrahedron(leng, thickness, segs_per_side, line_fn); + rotate([0, 180, 0]) + translate([0, -leng / 2 * tan(30), 0]) + string_tetrahedron(leng, thickness, segs_per_side, line_fn); + base(leng, thickness, line_fn); } diff --git a/examples/superformula_vase.scad b/examples/superformula_vase.scad index bd97032c..b64b8592 100644 --- a/examples/superformula_vase.scad +++ b/examples/superformula_vase.scad @@ -64,8 +64,8 @@ module superformula_vase(phi_step, m, n, n3, d, r1, r2, h1, h2, t_step, twist) { } linear_extrude(d) - rotate(twist - twist / len(sections)) - polygon(superformula2); + rotate(twist - twist / len(sections)) + polygon(superformula2); } superformula_vase(phi_step, m, n, n3, d, r1, r2, h1, h2, t_step, twist); diff --git a/examples/taiwan/cargo_container_landmark.scad b/examples/taiwan/cargo_container_landmark.scad index f031b1f1..23983488 100644 --- a/examples/taiwan/cargo_container_landmark.scad +++ b/examples/taiwan/cargo_container_landmark.scad @@ -32,8 +32,9 @@ module cargo_container_landmark() { module cargoL1() { translate([cargo_height, 0, -cargo20ft_len]) - rotate([0, -90, 0]) - cargo20ft(); + rotate([0, -90, 0]) + cargo20ft(); + cargo40ft(); } @@ -41,8 +42,9 @@ module cargo_container_landmark() { translate([-40, -10, 38.75]) rotate([18.315, 17.75, 0]) { translate([cargo40ft_len + cargo_width, cargo_width - cargo20ft_len, 0]) - rotate(90) - cargo20ft(); + rotate(90) + cargo20ft(); + translate([cargo20ft_len + cargo_width, -cargo20ft_len, 0]) cargo20ft(); @@ -52,21 +54,22 @@ module cargo_container_landmark() { translate([cargo_width, cargo20ft_len, -cargo20ft_len]) { translate([cargo20ft_len, 0, cargo_height]) - rotate([0, -90, 0]) - cargo40ft(); + rotate([0, -90, 0]) + cargo40ft(); + cargo20ft(); } cargoL1(); translate([cargo_width, cargo_width, -cargo20ft_len]) - rotate([0, 0, 90]) - cargo20ft(); + rotate([0, 0, 90]) + cargo20ft(); } if(platform == "YES") { color("black") - box_extrude(height = 2, shell_thickness = 1) - circle(75, $fn = 96); + box_extrude(height = 2, shell_thickness = 1) + circle(75, $fn = 96); } } @@ -86,10 +89,11 @@ module cargo_container(leng, width, height) { step_x = leng / nums; half_step_x = step_x * 0.5; points = [for(i = [0:nums - 1]) [-half_leng + i * step_x + half_step_x, 0]]; + along_with(points) - rotate([-90, 90, 0]) - linear_extrude(thickness, scale = [0.7, 0.9], center = true) - square([half_step_x, height - edge], center = true); + rotate([-90, 90, 0]) + linear_extrude(thickness, scale = [0.7, 0.9], center = true) + square([half_step_x, height - edge], center = true); } module door() { @@ -99,8 +103,8 @@ module cargo_container(leng, width, height) { for(i = [-1:1]) { translate([-height / 4.25 * i, 0, z]) - linear_extrude(h, scale = 0.95) - square(size, center = true); + linear_extrude(h, scale = 0.95) + square(size, center = true); } } } @@ -112,8 +116,8 @@ module cargo_container(leng, width, height) { module side() { translate([half_leng, half_w - half_thickness + d_offset, half_h]) - rotate([90, 0, 0]) - railing(rails, leng, thickness); + rotate([90, 0, 0]) + railing(rails, leng, thickness); } @@ -125,9 +129,9 @@ module cargo_container(leng, width, height) { union() { // front translate([-d_offset, 0, half_h]) - rotate([0, 90, 0]) - linear_extrude(thickness, scale = 0.95) - square([height * 0.95, width * 0.95], center = true); + rotate([0, 90, 0]) + linear_extrude(thickness, scale = 0.95) + square([height * 0.95, width * 0.95], center = true); // back translate([leng - half_thickness + d_offset, 0, half_h]) @@ -136,9 +140,9 @@ module cargo_container(leng, width, height) { // top translate([half_leng, 0, height - half_thickness + d_offset]) - rotate([180, 0, 0]) - scale([1, (width - edge) / height, 1]) - railing(rails, leng, thickness); + rotate([180, 0, 0]) + scale([1, (width - edge) / height, 1]) + railing(rails, leng, thickness); side(); mirror([0, 1, 0]) @@ -147,8 +151,8 @@ module cargo_container(leng, width, height) { // bottom translate([half_leng, half_w, -height / 400]) - linear_extrude(height / 80, scale = 0.95) - square([leng * 0.975, width * 0.9], center = true); + linear_extrude(height / 80, scale = 0.95) + square([leng * 0.975, width * 0.9], center = true); } translate([0, 0, half_h]) diff --git a/examples/taiwan/dancing_taiwan.scad b/examples/taiwan/dancing_taiwan.scad index 9d803909..7dcd0e2a 100644 --- a/examples/taiwan/dancing_taiwan.scad +++ b/examples/taiwan/dancing_taiwan.scad @@ -59,9 +59,9 @@ module dancing_formosan(x1, x2, x3, y1, y2, y3, twist, t_step) { } translate([0, 0, -2]) - linear_extrude(2) - rotate(twist - twist / len(sections)) - polygon(taiwan); + linear_extrude(2) + rotate(twist - twist / len(sections)) + polygon(taiwan); } diff --git a/examples/taiwan/leopard_cat_taiwan.scad b/examples/taiwan/leopard_cat_taiwan.scad index 923094d1..2b8cf613 100644 --- a/examples/taiwan/leopard_cat_taiwan.scad +++ b/examples/taiwan/leopard_cat_taiwan.scad @@ -135,8 +135,9 @@ levels = [ dots = px_gray(levels, center = true, invert = true, normalize = true); linear_extrude(1.5) difference() { translate([6.5, -10]) - rotate(22.5) - polygon(shape_taiwan(250)); + rotate(22.5) + polygon(shape_taiwan(250)); + render() for(dot = dots) { translate(dot[0]) square(0.7 * dot[1]); diff --git a/examples/taiwan/spiral_cube.scad b/examples/taiwan/spiral_cube.scad index 3f021315..d427358f 100644 --- a/examples/taiwan/spiral_cube.scad +++ b/examples/taiwan/spiral_cube.scad @@ -13,32 +13,33 @@ module spiral_cube(leng, leng_diff, min_leng) { if(current_leng > min_leng && current_leng > leng_diff && half_leng > pre_height) { translate([0, 0, pre_height]) - scale([factor, factor, 1]) - children(); + scale([factor, factor, 1]) + children(); rotate(atan2(leng_diff, current_leng - leng_diff)) - spiral_stack( - sqrt(pow_leng_diff + pow(current_leng - leng_diff, 2)), - thickness + pre_height, - i + 1 - ) children(); + spiral_stack( + sqrt(pow_leng_diff + pow(current_leng - leng_diff, 2)), + thickness + pre_height, + i + 1 + ) children(); } else if(half_leng > pre_height) { translate([0, 0, pre_height]) - scale([factor, factor, (half_leng - pre_height) / thickness]) - children(); + scale([factor, factor, (half_leng - pre_height) / thickness]) + children(); } } module spiral_squares() { difference() { translate([0, 0, -half_leng]) - spiral_stack(leng) - translate([0, 0, thickness / 2]) - cube([leng , leng, thickness], center = true); + spiral_stack(leng) + translate([0, 0, thickness / 2]) + cube([leng , leng, thickness], center = true); + translate([0, 0, 0.001]) - linear_extrude(leng) - square(leng, center = true); + linear_extrude(leng) + square(leng, center = true); } } @@ -66,13 +67,14 @@ module base(leng) { difference() { difference() { sphere(r); + translate([0, 0, -r]) - linear_extrude(r) - square(r * 2, center = true); + linear_extrude(r) + square(r * 2, center = true); } translate([0, 0, leng * sqrt(3) / 2 + leng / 15]) - rotate([45, atan2(1, sqrt(2)), 0]) - cube(leng * 0.99, center = true); + rotate([45, atan2(1, sqrt(2)), 0]) + cube(leng * 0.99, center = true); } } diff --git a/examples/text_box.scad b/examples/text_box.scad index 999ed248..340ca133 100644 --- a/examples/text_box.scad +++ b/examples/text_box.scad @@ -21,20 +21,22 @@ module text_container(t, font_size, font_name, r_round_edge, container_height, t difference() { linear_extrude(container_height) minkowski_text(t, font_size, font_name, r_round_edge); + translate([0, 0, thickness]) - linear_extrude(container_height - thickness) - offset(r = -thickness) - minkowski_text(t, font_size, font_name, r_round_edge); + linear_extrude(container_height - thickness) + offset(r = -thickness) + minkowski_text(t, font_size, font_name, r_round_edge); } } module text_lid(t, font_size, font_name, r_round_edge, container_height, lid_height, thickness, spacing) { translate([0, 0, lid_height - thickness]) - linear_extrude(thickness) - offset(r = spacing + thickness) - minkowski_text(t, font_size, font_name, r_round_edge); + linear_extrude(thickness) + offset(r = spacing + thickness) + minkowski_text(t, font_size, font_name, r_round_edge); - linear_extrude(lid_height) difference() { + linear_extrude(lid_height) + difference() { offset(r = spacing + thickness) minkowski_text(t, font_size, font_name, r_round_edge); offset(r = spacing) diff --git a/examples/text_sphere.scad b/examples/text_sphere.scad index fb15340c..81b5f258 100644 --- a/examples/text_sphere.scad +++ b/examples/text_sphere.scad @@ -26,7 +26,8 @@ module text_sphere(tx, font_name, thickness) { end_angle = end_angle ); - rotate(-180 / $fn) sphere_spiral_extrude( + rotate(-180 / $fn) + sphere_spiral_extrude( [ [thickness, half_thickness], [-half_thickness, half_thickness], @@ -43,16 +44,17 @@ module text_sphere(tx, font_name, thickness) { for(i = [0:len(points_angles) - 1]) { pa = points_angles[i]; - translate(pa[0]) rotate(pa[1] + [0, 8, 0]) - rotate([90, 0, 90]) - linear_extrude(half_thickness) - translate([0, -10, 0]) - text(tx[i], font = font_name, halign = "center"); + translate(pa[0]) + rotate(pa[1] + [0, 8, 0]) + rotate([90, 0, 90]) + linear_extrude(half_thickness) + translate([0, -10, 0]) + text(tx[i], font = font_name, halign = "center"); } translate([0, 0, -radius]) - linear_extrude(thickness * 2.5) - circle(radius / 2); + linear_extrude(thickness * 2.5) + circle(radius / 2); } text_sphere(tx, font_name, thickness); \ No newline at end of file diff --git a/examples/text_tower.scad b/examples/text_tower.scad index 5067a068..ab2edb07 100644 --- a/examples/text_tower.scad +++ b/examples/text_tower.scad @@ -26,14 +26,14 @@ module text_tower(tx, font_name, radius, height, thickness) { ); for(i = [0:len(points) - 1]) { translate(points[i]) - rotate([90, 0, 90 + angle_step * i]) - linear_extrude(thickness, center = true) - text( - tx[i], - font = font_name, - size = font_size, - halign = "center" - ); + rotate([90, 0, 90 + angle_step * i]) + linear_extrude(thickness, center = true) + text( + tx[i], + font = font_name, + size = font_size, + halign = "center" + ); } rotate(-half_angle_step) @@ -53,9 +53,10 @@ module text_tower(tx, font_name, radius, height, thickness) { translate([0, 0, -font_size - half_thickness]) body(); + rotate(-half_angle_step) - translate([0, 0, -font_size - thickness]) - cylinder(h = font_size, r = radius + thickness); + translate([0, 0, -font_size - thickness]) + cylinder(h = font_size, r = radius + thickness); } text_tower(tx, font_name, radius, height, thickness, $fn = 24); \ No newline at end of file diff --git a/examples/triangle2square/triangle2square_box.scad b/examples/triangle2square/triangle2square_box.scad index b8e484d8..d347ba7a 100644 --- a/examples/triangle2square/triangle2square_box.scad +++ b/examples/triangle2square/triangle2square_box.scad @@ -52,9 +52,12 @@ module triangle2square_box(type, tri_side_leng, height, spacing, ring_width, sha } else if(type == "COVER") { box_extrude(height = ring_width * 2, shell_thickness = ring_width) - mirror([1, 0, 0]) - offset(-ring_width - spacing) 2d_tri_square(); - linear_extrude(ring_width) mirror([1, 0, 0]) 2d_tri_square(); + mirror([1, 0, 0]) + offset(-ring_width - spacing) 2d_tri_square(); + + linear_extrude(ring_width) + mirror([1, 0, 0]) + 2d_tri_square(); } } diff --git a/examples/triangle2square/triangle2square_pendant.scad b/examples/triangle2square/triangle2square_pendant.scad index aef07e77..26d4c01c 100644 --- a/examples/triangle2square/triangle2square_pendant.scad +++ b/examples/triangle2square/triangle2square_pendant.scad @@ -56,8 +56,8 @@ difference() { if(chain_hole == "YES") { translate([spacing * 1.5, spacing, height / 2]) linear_extrude(chain_hole_width, center = true) - hollow_out(chain_hole_width) - circle(shaft_r + spacing + chain_hole_width); + hollow_out(chain_hole_width) + circle(shaft_r + spacing + chain_hole_width); } } diff --git a/examples/twist_bottle.scad b/examples/twist_bottle.scad index 7f82c94a..48fadf78 100644 --- a/examples/twist_bottle.scad +++ b/examples/twist_bottle.scad @@ -20,8 +20,8 @@ module twist_bottle(model, height, thickness, twist, spacing, convexity, slices) module outer_container() { translate([0, 0, thickness]) - linear_extrude(height = height, twist = twist, slices = slices) - hollow_out(thickness) children(); + linear_extrude(height = height, twist = twist, slices = slices) + hollow_out(thickness) children(); linear_extrude(thickness) children(); @@ -34,9 +34,9 @@ module twist_bottle(model, height, thickness, twist, spacing, convexity, slices) children(); translate([0, 0, height]) - rotate(twist) - linear_extrude(thickness) - children(); + rotate(twist) + linear_extrude(thickness) + children(); } if(model == "Outer") { @@ -44,9 +44,9 @@ module twist_bottle(model, height, thickness, twist, spacing, convexity, slices) children(); } else if(model == "Inner") { translate([0, 0, height + thickness]) - rotate([180, 0, 0]) - inner_container() - children(); + rotate([180, 0, 0]) + inner_container() + children(); } } @@ -59,18 +59,18 @@ module heart(radius, center = false) { $fn = 48; translate([-radius * cos45, 0, 0]) - rotate(-45) union() { - circle(radius); - translate([0, -radius, 0]) - square(diameter); - } + rotate(-45) { + circle(radius); + translate([0, -radius, 0]) + square(diameter); + } } offsetX = center ? 0 : radius + radius * cos(45); offsetY = center ? 1.5 * radius * sin45 - 0.5 * radius : 3 * radius * sin45; - translate([offsetX, offsetY, 0]) union() { + translate([offsetX, offsetY, 0]) { heart_sub_component(radius); mirror([1, 0, 0]) heart_sub_component(radius); } @@ -80,18 +80,19 @@ if(shape == "Flower") { twist_bottle(model, height, thickness, twist, spacing, slices) union() { for(i = [0:3]) { rotate(90 * i) - translate([radius * 0.5, 0, 0]) - circle(radius * 0.5); + translate([radius * 0.5, 0, 0]) + circle(radius * 0.5); } } } else if(shape == "Circle") { - twist_bottle(model, height, thickness, twist, spacing, slices) difference() { + twist_bottle(model, height, thickness, twist, spacing, slices) + difference() { circle(radius); union() { for(a = [0:120:240]) { rotate(a) - translate([radius, 0, 0]) - circle(radius / 4); + translate([radius, 0, 0]) + circle(radius / 4); } } } diff --git a/examples/vampire_pen_holder.scad b/examples/vampire_pen_holder.scad index e80caff5..2e15b48d 100644 --- a/examples/vampire_pen_holder.scad +++ b/examples/vampire_pen_holder.scad @@ -31,8 +31,8 @@ module vampire_pen_holder() { circle(radius); translate([0, 0, holder_round_r]) - linear_extrude(holder_height) - hollow_out(shell_thickness = 4) circle(30 + 5); + linear_extrude(holder_height) + hollow_out(shell_thickness = 4) circle(30 + 5); } module sun_glasses() { @@ -40,14 +40,11 @@ module vampire_pen_holder() { thickness = 4; rotate(-135) - bend_extrude(size = [80, 20], thickness = thickness, angle = 90) - translate([40, 10]) - - union() { - polygon(glasses_path); - mirror([1, 0, 0]) polygon(glasses_path); - } - + bend_extrude(size = [80, 20], thickness = thickness, angle = 90) + translate([40, 10]) { + polygon(glasses_path); + mirror([1, 0, 0]) polygon(glasses_path); + } } module cloak() { @@ -71,16 +68,16 @@ module vampire_pen_holder() { feet(); color("white") - translate([0, 0, feet_height - holder_round_r]) - holder(); + translate([0, 0, feet_height - holder_round_r]) + holder(); color("black") - translate([0, 12.5, holder_height * 5 / 6]) - sun_glasses(); + translate([0, 12.5, holder_height * 5 / 6]) + sun_glasses(); color("red") - translate([-80, holder_round_r + 0.5, holder_height + feet_height - holder_round_r]) - cloak(); + translate([-80, holder_round_r + 0.5, holder_height + feet_height - holder_round_r]) + cloak(); } vampire_pen_holder(); \ No newline at end of file diff --git a/examples/voronoi_vase.scad b/examples/voronoi_vase.scad index 860486b1..4828e269 100644 --- a/examples/voronoi_vase.scad +++ b/examples/voronoi_vase.scad @@ -58,12 +58,9 @@ module voronoi_vase(r, h, thickness, num_of_pts, fn, profile_step) { polygon([for(pt = sections[0]) [pt[0], pt[1]]]); translate([0, 0, h]) - linear_extrude(thickness) - hollow_out(thickness) - polygon([for(pt = sections[last_section_i]) [pt[0], pt[1]]]); - - - + linear_extrude(thickness) + hollow_out(thickness) + polygon([for(pt = sections[last_section_i]) [pt[0], pt[1]]]); } voronoi_vase(r, h, thickness, num_of_pts, fn, profile_step); \ No newline at end of file diff --git a/examples/walk_torus83_fort.scad b/examples/walk_torus83_fort.scad index fbcaa51e..c9c0df7f 100644 --- a/examples/walk_torus83_fort.scad +++ b/examples/walk_torus83_fort.scad @@ -40,20 +40,21 @@ module wall(radius, height, thickness) { eight_pts_star(ro - thickness, thickness); translate([0, 0, height]) - linear_extrude(half_thickness) - difference() { - eight_pts_star(ro - thickness, thickness / 4); - - union() { - for(i = [0:7]) { - rotate(22.5 + i * 45) - translate([-ro, 0]) rotate(-22.5) { - bk(); - rotate(45) bk(); - } - } + linear_extrude(half_thickness) + difference() { + eight_pts_star(ro - thickness, thickness / 4); + + union() { + for(i = [0:7]) { + rotate(22.5 + i * 45) + translate([-ro, 0]) + rotate(-22.5) { + bk(); + rotate(45) bk(); } } + } + } } module walk_torus83_fort(radius, thickness, height) { @@ -124,7 +125,7 @@ module walk_torus83_fort(radius, thickness, height) { stairs(height, stair_number); // walkway without doors - translate([-leng * 2, 0]) + translate([-leng * 2, 0]) rotate([180, 0, 180]) { translate([half_leng2, 0]) square([leng2, height], center = true); @@ -154,11 +155,11 @@ module walk_torus83_fort(radius, thickness, height) { offset = leng / 1.325; for(i = [0:7]) { rotate(45 * i) - translate([offset, offset, 0]) - one_burst(leng, thickness, height, stair_number); + translate([offset, offset, 0]) + one_burst(leng, thickness, height, stair_number); rotate(45 * i + 22.5) - translate([radius + thickness / 1.75, 0]) - tower(thickness * 1.25, height * 1.125); + translate([radius + thickness / 1.75, 0]) + tower(thickness * 1.25, height * 1.125); } }