rubber_duck_debugging.scad
1 use <polyhedra/geom_icosahedron.scad> 2 use <polyline_join.scad> 3 use <bend_extrude.scad> 4 5 detail = 1; 6 object = "OpenSCAD"; 7 font_size = 10; 8 thickness = 4; 9 bend_angle = 125; 10 pitch_angle = 5; 11 12 rubber_duck_debugging(detail, object, font_size, thickness, bend_angle, pitch_angle); 13 14 module rubber_duck_debugging(detail, object, font_size, thickness, bend_angle, pitch_angle) { 15 r = font_size * len(object) * 0.85 * 360 / bend_angle / 2 / PI; 16 difference() { 17 if($preview) { 18 %duck(detail); 19 } 20 else { 21 duck(detail); 22 } 23 rotate([-pitch_angle, 0, 0]) 24 translate([0, r - 36, -font_size / 2]) 25 rotate(180 + (180 - bend_angle) / 2) 26 bend_extrude( 27 size = [font_size * len(object) * 0.85, font_size * 1.25], thickness = thickness, 28 angle = bend_angle 29 ) 30 translate([0, font_size / 3]) 31 text( 32 object, 33 size = font_size, 34 font = "Courier New:style=Bold" 35 ); 36 } 37 } 38 39 module duck(detail) { 40 points_faces = geom_icosahedron(1.02, detail); 41 module icosphere() { 42 polyhedron(points_faces[0], points_faces[1]); 43 } 44 45 module frillsAndUpperBeak() { 46 pts = [ 47 [0, 16, 10], 48 [0, -2, 13], 49 [0, -20, 8], 50 [0, -10, 28], 51 [0, -6, 52], 52 [0, -13, 50], 53 [0, -16, 46], 54 [0, -23.5, 41.5], 55 [0, -26.9, 41.9], 56 [0, -31.9, 45.3] 57 ]; 58 59 polyline_join(pts) { 60 scale([5, 5, 5]) icosphere(); 61 scale([10, 10, 10]) icosphere(); 62 scale([15, 13, 15]) icosphere(); 63 scale([5, 5, 5]) icosphere(); 64 scale([6, 8, 5]) icosphere(); 65 scale([6, 4, 6.5]) icosphere(); 66 scale([5, 5, 5]) icosphere(); 67 scale([11, 5, 4.7]) icosphere(); 68 scale([9.9, 3, 4]) icosphere(); 69 scale([5, 3, 2]) icosphere(); 70 }; 71 } 72 73 module bodyBulk() { 74 pts = [ 75 [0, 31, 25], 76 [0, 27, 12], 77 [0, 16, 0], 78 [0, 6, 0], 79 [0, -10, 3], 80 [0, -10, 15], 81 [0, -10, 29], 82 [0, -7, 41], 83 [0, -20, 37.5], 84 [0, -28, 38] 85 ]; 86 87 polyline_join(pts) { 88 scale([3.5, 3.5, 3.5]) icosphere(); 89 scale([10, 10, 10]) icosphere(); 90 scale([15, 18, 16]) icosphere(); 91 scale([21, 20, 20]) icosphere(); 92 scale([28, 25, 22]) icosphere(); 93 scale([9, 9, 12]) icosphere(); 94 scale([8, 10, 8]) icosphere(); 95 scale([15, 17, 17]) icosphere(); 96 scale([13, 10, 4]) icosphere(); 97 scale([8, 6, 2]) icosphere(); 98 }; 99 } 100 101 module beakDetalAndFlank() { 102 pts = [ 103 [0, -33, 46.5], 104 [3, -32.5, 46], 105 [6, -30.5, 43], 106 [7.7, -28, 41.6], 107 [9, -23, 42], 108 [8, -19, 43], 109 [8, -16, 46], 110 [5, -18, 48], 111 [8, -16, 46], 112 [0, -6, 46], 113 [0, -10, 8], 114 [9, -10, 4], 115 [7, 0, 3], 116 [3, 10, 3] 117 ]; 118 119 polyline_join(pts) { 120 scale([1.5, 2.5, 2.5]) icosphere(); 121 scale([1.5, 2.5, 2.5]) icosphere(); 122 scale([1.5, 2.5, 2]) icosphere(); 123 scale([2.5, 2.5, 1.5]) icosphere(); 124 scale([3, 2, 2]) icosphere(); 125 scale([3, 3, 3]) icosphere(); 126 scale([2, 2, 2]) icosphere(); 127 scale([4, 4, 4]) icosphere(); 128 scale([2, 2, 2]) icosphere(); 129 scale([2, 2, 2]) icosphere(); 130 scale([10, 10, 10]) icosphere(); 131 scale([20, 20, 17]) icosphere(); 132 scale([19, 20, 18]) icosphere(); 133 scale([18, 20, 15]) icosphere(); 134 }; 135 } 136 137 union() { 138 frillsAndUpperBeak(); 139 bodyBulk(); 140 141 beakDetalAndFlank(); 142 mirror([1, 0, 0]) 143 beakDetalAndFlank(); 144 } 145 }