From b420a9bae3d8977d1db028fbb859a745bcc10729 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 15 Mar 2017 15:38:59 +0800 Subject: [PATCH] tab to space --- src/arc.scad | 12 +++++------ src/line2d.scad | 50 ++++++++++++++++++++++----------------------- src/polyline2d.scad | 24 +++++++++++----------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/arc.scad b/src/arc.scad index 0283b228..964d8d4c 100644 --- a/src/arc.scad +++ b/src/arc.scad @@ -19,11 +19,11 @@ LINE_INWARD = 2; module arc(radius, angles, width, width_mode = LINE_CROSS, fn = 24) { w_offset = width_mode == LINE_CROSS ? [width / 2, -width / 2] : ( - width_mode == LINE_INWARD ? [0, -width] : [width, 0] - ); - - difference() { - sector(radius + w_offset[0], angles, fn); - sector(radius + w_offset[1], angles, fn); + width_mode == LINE_INWARD ? [0, -width] : [width, 0] + ); + + difference() { + sector(radius + w_offset[0], angles, fn); + sector(radius + w_offset[1], angles, fn); } } \ No newline at end of file diff --git a/src/line2d.scad b/src/line2d.scad index b8e83bb0..14469b56 100644 --- a/src/line2d.scad +++ b/src/line2d.scad @@ -17,14 +17,14 @@ CAP_ROUND = 2; module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_fn = 24) { $fn = round_fn; - half_width = 0.5 * width; + half_width = 0.5 * width; atan_angle = atan2(p2[1] - p1[1], p2[0] - p1[0]); angle = 90 - atan_angle; - + offset_x = half_width * cos(angle); offset_y = half_width * sin(angle); - + offset1 = [-offset_x, offset_y]; offset2 = [offset_x, -offset_y]; @@ -32,27 +32,27 @@ module line2d(p1, p2, width, p1Style = CAP_SQUARE, p2Style = CAP_SQUARE, round_ p1 + offset1, p2 + offset1, p2 + offset2, p1 + offset2 ]); - - module square_end(point) { + + module square_end(point) { translate(point) - rotate(atan_angle) - square(width, center = true); - } - - module round_end(point) { - translate(point) - circle(half_width, center = true); - } - - if(p1Style == CAP_SQUARE) { - square_end(p1); - } else if(p1Style == CAP_ROUND) { - round_end(p1); - } - - if(p2Style == CAP_SQUARE) { - square_end(p2); - } else if(p2Style == CAP_ROUND) { - round_end(p2); - } + rotate(atan_angle) + square(width, center = true); + } + + module round_end(point) { + translate(point) + circle(half_width, center = true); + } + + if(p1Style == CAP_SQUARE) { + square_end(p1); + } else if(p1Style == CAP_ROUND) { + round_end(p1); + } + + if(p2Style == CAP_SQUARE) { + square_end(p2); + } else if(p2Style == CAP_ROUND) { + round_end(p2); + } } \ No newline at end of file diff --git a/src/polyline2d.scad b/src/polyline2d.scad index 2f17df03..946803bc 100644 --- a/src/polyline2d.scad +++ b/src/polyline2d.scad @@ -12,21 +12,21 @@ module polyline2d(points, width, startingStyle = CAP_SQUARE, endingStyle = CAP_SQUARE, round_fn = 24) { module line_segment(index) { - styles = index == 1 ? [startingStyle, CAP_ROUND] : ( - index == len(points) - 1 ? [CAP_ROUND, endingStyle] : [ - CAP_ROUND, CAP_ROUND - ] - ); - - line2d(points[index - 1], points[index], width, - p1Style = styles[0], p2Style = styles[1], - round_fn = round_fn); - } + styles = index == 1 ? [startingStyle, CAP_ROUND] : ( + index == len(points) - 1 ? [CAP_ROUND, endingStyle] : [ + CAP_ROUND, CAP_ROUND + ] + ); + + line2d(points[index - 1], points[index], width, + p1Style = styles[0], p2Style = styles[1], + round_fn = round_fn); + } module polyline2d_inner(points, index) { if(index < len(points)) { - line_segment(index); - polyline2d_inner(points, index + 1); + line_segment(index); + polyline2d_inner(points, index + 1); } }