rounded_square.scad
1 /** 2 * rounded_square.scad 3 * 4 * @copyright Justin Lin, 2017 5 * @license https://opensource.org/licenses/lgpl-3.0.html 6 * 7 * @see https://openhome.cc/eGossip/OpenSCAD/lib3x-rounded_square.html 8 * 9 **/ 10 11 use <__comm__/__trapezium.scad> 12 13 module rounded_square(size, corner_r, center = false) { 14 is_flt = is_num(size); 15 x = is_flt ? size : size.x; 16 y = is_flt ? size : size.y; 17 18 position = center ? [0, 0] : [x / 2, y / 2]; 19 points = __trapezium( 20 length = x, 21 h = y, 22 round_r = corner_r 23 ); 24 25 translate(position) 26 polygon(points); 27 28 // hook for testing 29 test_rounded_square(position, points); 30 } 31 32 // override it to test 33 module test_rounded_square(position, points) { 34 }