mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Fixed anchoring of square and circle
This commit is contained in:
parent
a38441a548
commit
446ea5c911
1 changed files with 2 additions and 1 deletions
|
@ -45,6 +45,7 @@ module square(size, center=undef, anchor=FRONT+LEFT, spin=0) {
|
||||||
|
|
||||||
function square(size, center=undef, anchor=FRONT+LEFT, spin=0) =
|
function square(size, center=undef, anchor=FRONT+LEFT, spin=0) =
|
||||||
let(
|
let(
|
||||||
|
anchor = center==true? CENTER : center==false? FRONT+LEFT : anchor,
|
||||||
size = is_num(size)? [size,size] : point2d(size),
|
size = is_num(size)? [size,size] : point2d(size),
|
||||||
s=size/2
|
s=size/2
|
||||||
) rot(spin, p=move(-vmul(anchor,s), p=[[-s.x,-s.y], [-s.x,s.y], [s.x,s.y], [s.x,-s.y]]));
|
) rot(spin, p=move(-vmul(anchor,s), p=[[-s.x,-s.y], [-s.x,s.y], [s.x,s.y], [s.x,-s.y]]));
|
||||||
|
@ -87,7 +88,7 @@ function circle(r=undef, d=undef, anchor=CENTER, spin=0) =
|
||||||
r = get_radius(r=r, d=d, dflt=1),
|
r = get_radius(r=r, d=d, dflt=1),
|
||||||
sides = segs(r),
|
sides = segs(r),
|
||||||
pts = [for (i=[0:1:sides-1]) let(a=360-i*360/sides) r*[cos(a),sin(a)]]
|
pts = [for (i=[0:1:sides-1]) let(a=360-i*360/sides) r*[cos(a),sin(a)]]
|
||||||
) rot(spin, p=move(-vmul(anchor,s), p=pts));
|
) rot(spin, p=move(-normalize(anchor)*r, p=pts));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue