Corrected anchor positions, improved linear response of squareness, added example

This commit is contained in:
Alex Matulich 2024-12-05 16:59:58 -08:00
parent 72a2c1470a
commit 504c92bba9

View file

@ -2024,11 +2024,11 @@ module squircle(squareness=0.7, size=[10,10], anchor=CENTER, spin=0) {
anchors = [ anchors = [
for (i = [0:1:3]) let( for (i = [0:1:3]) let(
ca = 360 - i*90, ca = 360 - i*90,
cp = polar_to_xy(squircle_radius(squareness, bbox[0], ca), ca) cp = polar_to_xy(squircle_radius(squareness, bbox[0]/2, ca), ca)
) named_anchor(str("side",i), cp, unit(cp,BACK), 0), ) named_anchor(str("side",i), cp, unit(cp,BACK), 0),
for (i = [0:1:3]) let( for (i = [0:1:3]) let(
ca = 360-45 - i*90, ca = 360-45 - i*90,
cp = polar_to_xy(squircle_radius(squareness, bbox[0], ca), ca) cp = polar_to_xy(squircle_radius(squareness, bbox[0]/2, ca), ca)
) named_anchor(str("corner",i), cp, unit(cp,BACK), 0) ) named_anchor(str("corner",i), cp, unit(cp,BACK), 0)
]; ];
attachable(anchor,spin, two_d=true, path=path, extent=false, anchors=anchors) { attachable(anchor,spin, two_d=true, path=path, extent=false, anchors=anchors) {