Skip to content

Instantly share code, notes, and snippets.

@ali1234
Created August 13, 2023 01:58
Show Gist options
  • Save ali1234/60f1b5e220d221a7be1e6c5b7cc1a96e to your computer and use it in GitHub Desktop.
Save ali1234/60f1b5e220d221a7be1e6c5b7cc1a96e to your computer and use it in GitHub Desktop.
OpenSCAD rounding with offset
// Animation showing what the 4x offset rounding trick does.
$fs = 0.1;
$fa = 0.1;
function clamp(x) = min(max(x, 0), 1);
module timed_offset(t) {
a = clamp(t-1);
b = clamp(t-2.5);
c = clamp(t-4);
d = clamp(t-5.5);
offset(d) offset(-c) offset(-b) offset(a) children();
}
module some_shape() {
difference() {
square(10, center=true);
translate([2, 0]) square([8, 4], center=true);
}
}
timed_offset($t * 7.5) some_shape();
@ali1234
Copy link
Author

ali1234 commented Aug 13, 2023

offset

(You might have to click play on the above to see the animation.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment