Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (62 sloc) 1.72 KB
// helper module for drawing rectangles with rounded borders
//
// (c) 2013 Felipe C. da S. Sanches <fsanches@metamaquina.com.br>
// Lincensed under the terms of the GNU General Public License
// version 3 (or later).
module rounded_square(dim, corners=[10,10,10,10], center=false){
w=dim[0];
h=dim[1];
if (center){
translate([-w/2, -h/2])
rounded_square_(dim, corners=corners);
}else{
rounded_square_(dim, corners=corners);
}
}
module rounded_square_(dim, corners, center=false){
w=dim[0];
h=dim[1];
render(){
difference(){
square([w,h]);
if (corners[0])
square([corners[0], corners[0]]);
if (corners[1])
translate([w-corners[1],0])
square([corners[1], corners[1]]);
if (corners[2])
translate([0,h-corners[2]])
square([corners[2], corners[2]]);
if (corners[3])
translate([w-corners[3], h-corners[3]])
square([corners[3], corners[3]]);
}
if (corners[0])
translate([corners[0], corners[0]])
intersection(){
circle(r=corners[0]);
translate([-corners[0], -corners[0]])
square([corners[0], corners[0]]);
}
if (corners[1])
translate([w-corners[1], corners[1]])
intersection(){
circle(r=corners[1]);
translate([0, -corners[1]])
square([corners[1], corners[1]]);
}
if (corners[2])
translate([corners[2], h-corners[2]])
intersection(){
circle(r=corners[2]);
translate([-corners[2], 0])
square([corners[2], corners[2]]);
}
if (corners[3])
translate([w-corners[3], h-corners[3]])
intersection(){
circle(r=corners[3]);
square([corners[3], corners[3]]);
}
}
}