diff --git a/src/case.scad b/src/case.scad index bd61605..a3277af 100644 --- a/src/case.scad +++ b/src/case.scad @@ -25,6 +25,48 @@ module _PhoneBulkLayer(tol=tol) } } +module _DilatedBody(ButtonStyle) { + body = 0; + buttons = 1; + minkowski() { + sphere(r=Thickness); + union() { + children(body); + if (ButtonStyle=="extrude") { + children(buttons); + }; + } + } +} + +module _PeripheralCutouts(ButtonStyle) { + buttons = 0; + ports = 1; + camera = 2; + union() { + minkowski() { + sphere(r=MarginCameraCut); + children(camera); + }; + // restrict these cutouts to just the phone bulk -- don't let them impact the back of the case + intersection() { + _PhoneBulkLayer(); + union() { + if (ButtonStyle == "cut") { + minkowski() { + sphere(r=MarginButtonsCut); + children(buttons); + }; + }; + minkowski() { + sphere(r=MarginPortsCut); + children(ports); + }; + }; + }; + }; +}; + module _FrontFace(tol=tol) { color("thistle") difference() { @@ -75,37 +117,17 @@ module Case(ButtonStyle="extrude") color("DarkSlateGray") difference() { // start by dilating the phone - minkowski() { - sphere(r=Thickness); - union() { - children(body); - if (ButtonStyle=="extrude") { - children(buttons); - }; - } - } + _DilatedBody(ButtonStyle=ButtonStyle) { + children(body); + children(buttons); + }; // then subtract away phone and cutouts union() { - minkowski() { - sphere(r=MarginCameraCut); + _PeripheralCutouts(ButtonStyle=ButtonStyle) { + children(buttons); + children(ports); children(camera); }; - // restrict these cutouts to just the phone bulk -- don't let them impact the back of the case - intersection() { - _PhoneBulkLayer(); - union() { - if (ButtonStyle == "cut") { - minkowski() { - sphere(r=MarginButtonsCut); - children(buttons); - }; - }; - minkowski() { - sphere(r=MarginPortsCut); - children(ports); - }; - }; - }; // subtract the phone children(body); // subtract the buttons (we want to give them a buffer)