From 3bbed7e8c0d058d43c45b688e8b55d4077a5be3f Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 13 Feb 2020 17:19:46 +0800 Subject: [PATCH] add arc_tiled_lines --- examples/arc_tiled_lines.scad | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/arc_tiled_lines.scad diff --git a/examples/arc_tiled_lines.scad b/examples/arc_tiled_lines.scad new file mode 100644 index 00000000..4a976098 --- /dev/null +++ b/examples/arc_tiled_lines.scad @@ -0,0 +1,40 @@ +use ; +use ; +use ; +use ; + +module arc_tiled_lines(size, angle, step, line_width = 1) { + sizexy = is_num(size) ? [size, size] : size; + s = is_undef(step) ? line_width * 2 : step; + + function rand_diagonal_line_pts(x, y, size) = + rand(0, 1) >= 0.5 ? [[x, y], [x + size, y + size]] : [[x + size, y], [x, y + size]]; + + lines = [ + for(x = [0:s:sizexy[0] - s]) + for(y = [0:s:sizexy[1] - s]) + rand_diagonal_line_pts(x, y, s) + ]; + + for(line = lines) { + pts = [for(p = line) tf_ring(size, p, size[0], angle)]; + hull_polyline2d(pts, width = line_width); + } + + arc_width = line_width * 2; + arc(radius = size[0], angle = angle, width = arc_width, $fn = 36); + arc(radius = size[0] * 2, angle = angle, width = arc_width, $fn = 36); + + if(angle != 360) { + hull_polyline2d([[size[0], 0], [size[0] * 2, 0]], width = arc_width); + rotate(angle) + hull_polyline2d([[size[0], 0], [size[0] * 2, 0]], width = arc_width); + } +} + +size = [20, 100]; +line_width = .5; +step = 1; +angle = 360; + +arc_tiled_lines(size, angle, step, line_width);