From e6f96055cd8aac4357697befcaeebabb457d0770 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 25 May 2017 11:48:02 +0800 Subject: [PATCH] added messages --- src/rounded_square.scad | 14 ++++++++++++-- test/test_shape_ellipse.scad | 2 ++ test/test_shape_square.scad | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/rounded_square.scad b/src/rounded_square.scad index c67612d5..fc9ec941 100644 --- a/src/rounded_square.scad +++ b/src/rounded_square.scad @@ -22,9 +22,19 @@ module rounded_square(size, corner_r, center = false) { x = is_vt ? size[0] : size; y = is_vt ? size[1] : size; - translate(center ? [0, 0] : [x / 2, y / 2]) polygon(__trapezium( + position = center ? [0, 0] : [x / 2, y / 2]; + points = __trapezium( length = x, h = y, round_r = corner_r - )); + ); + + translate(position) + polygon(points); + + // hook for testing + test_rounded_square(position, points); +} + +module test_rounded_square(position, points) { } \ No newline at end of file diff --git a/test/test_shape_ellipse.scad b/test/test_shape_ellipse.scad index b89e0e7b..f248ace3 100644 --- a/test/test_shape_ellipse.scad +++ b/test/test_shape_ellipse.scad @@ -1,6 +1,8 @@ include ; include ; +echo("==== test_shape_ellipse ===="); + expected = [[40, 0], [39.1259, 4.15823], [36.5418, 8.13473], [32.3607, 11.7557], [26.7652, 14.8629], [20, 17.3205], [12.3607, 19.0211], [4.18114, 19.8904], [-4.18114, 19.8904], [-12.3607, 19.0211], [-20, 17.3205], [-26.7652, 14.8629], [-32.3607, 11.7557], [-36.5418, 8.13473], [-39.1259, 4.15823], [-40, 0], [-39.1259, -4.15823], [-36.5418, -8.13473], [-32.3607, -11.7557], [-26.7652, -14.8629], [-20, -17.3205], [-12.3607, -19.0211], [-4.18114, -19.8904], [4.18114, -19.8904], [12.3607, -19.0211], [20, -17.3205], [26.7652, -14.8629], [32.3607, -11.7557], [36.5418, -8.13473], [39.1259, -4.15823]]; actual = shape_ellipse([40, 20]); diff --git a/test/test_shape_square.scad b/test/test_shape_square.scad index e9250adb..5f54ddfc 100644 --- a/test/test_shape_square.scad +++ b/test/test_shape_square.scad @@ -1,6 +1,8 @@ include ; include ; +echo("==== test_shape_square ===="); + expected = [[20, -25], [21.9471, -24.6053], [23.5868, -23.4835], [24.6602, -21.8118], [25, -20], [25, 20], [24.6053, 21.9471], [23.4835, 23.5868], [21.8118, 24.6602], [20, 25], [-20, 25], [-21.8118, 24.6602], [-23.4835, 23.5868], [-24.6053, 21.9471], [-25, 20], [-25, -20], [-24.6602, -21.8118], [-23.5868, -23.4835], [-21.9471, -24.6053], [-20, -25]]; actual = shape_square(size = 50, corner_r = 5);