From 9743ba2790f641e8e71fd549bcf320e5cee02993 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Fri, 12 May 2017 15:21:45 +0800 Subject: [PATCH] refactored --- src/__private__/__nearest_multiple_of_4.scad | 2 +- src/rounded_square.scad | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/__private__/__nearest_multiple_of_4.scad b/src/__private__/__nearest_multiple_of_4.scad index a9ca9724..bb9b2af7 100644 --- a/src/__private__/__nearest_multiple_of_4.scad +++ b/src/__private__/__nearest_multiple_of_4.scad @@ -1,4 +1,4 @@ -function __multiple_of_4(n) = +function __nearest_multiple_of_4(n) = let( remain = n % 4 ) diff --git a/src/rounded_square.scad b/src/rounded_square.scad index 618ea658..b938b63b 100644 --- a/src/rounded_square.scad +++ b/src/rounded_square.scad @@ -13,14 +13,10 @@ include <__private__/__is_vector.scad>; include <__private__/__frags.scad>; +include <__private__/__nearest_multiple_of_4.scad>; module rounded_square(size, corner_r, center = false) { - frags = __frags(corner_r); - - remain = frags % 4; - corner_frags = (remain / 4) > 0.5 ? frags - remain + 4 : frags - remain; - - step_a = 360 / corner_frags; + step_a = 360 / __nearest_multiple_of_4(__frags(corner_r)); is_vt = __is_vector(size); x = is_vt ? size[0] : size;