Merge pull request #728 from adrianVmariano/master

rect center, stroke error message
This commit is contained in:
Revar Desmera 2021-11-12 13:28:38 -08:00 committed by GitHub
commit 647d327df5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 45 deletions

View file

@ -107,7 +107,7 @@ INCH = 25.4;
// Constant: LEFT // Constant: LEFT
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: RIGHT, FRONT, BACK, UP, DOWN, CENTER, ALLPOS, ALLNEG // See Also: RIGHT, FRONT, BACK, UP, DOWN, CENTER
// Description: Vector pointing left. [-1,0,0] // Description: Vector pointing left. [-1,0,0]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=LEFT); // cuboid(20, anchor=LEFT);
@ -115,7 +115,7 @@ LEFT = [-1, 0, 0];
// Constant: RIGHT // Constant: RIGHT
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: LEFT, FRONT, BACK, UP, DOWN, CENTER, ALLPOS, ALLNEG // See Also: LEFT, FRONT, BACK, UP, DOWN, CENTER
// Description: Vector pointing right. [1,0,0] // Description: Vector pointing right. [1,0,0]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=RIGHT); // cuboid(20, anchor=RIGHT);
@ -124,7 +124,7 @@ RIGHT = [ 1, 0, 0];
// Constant: FRONT // Constant: FRONT
// Aliases: FWD, FORWARD // Aliases: FWD, FORWARD
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: LEFT, RIGHT, BACK, UP, DOWN, CENTER, ALLPOS, ALLNEG // See Also: LEFT, RIGHT, BACK, UP, DOWN, CENTER
// Description: Vector pointing forward. [0,-1,0] // Description: Vector pointing forward. [0,-1,0]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=FRONT); // cuboid(20, anchor=FRONT);
@ -134,7 +134,7 @@ FORWARD = FRONT;
// Constant: BACK // Constant: BACK
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, UP, DOWN, CENTER, ALLPOS, ALLNEG // See Also: LEFT, RIGHT, FRONT, UP, DOWN, CENTER
// Description: Vector pointing back. [0,1,0] // Description: Vector pointing back. [0,1,0]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=BACK); // cuboid(20, anchor=BACK);
@ -143,7 +143,7 @@ BACK = [ 0, 1, 0];
// Constant: BOTTOM // Constant: BOTTOM
// Aliases: BOT, DOWN // Aliases: BOT, DOWN
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, BACK, UP, CENTER, ALLPOS, ALLNEG // See Also: LEFT, RIGHT, FRONT, BACK, UP, CENTER
// Description: Vector pointing down. [0,0,-1] // Description: Vector pointing down. [0,0,-1]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=BOTTOM); // cuboid(20, anchor=BOTTOM);
@ -154,33 +154,17 @@ DOWN = BOTTOM;
// Constant: TOP // Constant: TOP
// Aliases: UP // Aliases: UP
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, BACK, DOWN, CENTER, ALLPOS, ALLNEG // See Also: LEFT, RIGHT, FRONT, BACK, DOWN, CENTER
// Description: Vector pointing up. [0,0,1] // Description: Vector pointing up. [0,0,1]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=TOP); // cuboid(20, anchor=TOP);
TOP = [ 0, 0, 1]; TOP = [ 0, 0, 1];
UP = TOP; UP = TOP;
// Constant: ALLPOS
// Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, BACK, UP, DOWN, CENTER, ALLNEG
// Description: Vector pointing right, back, and up. [1,1,1]
// Example(3D): Usage with `anchor`
// cuboid(20, anchor=ALLPOS);
ALLPOS = [ 1, 1, 1]; // Vector pointing X+,Y+,Z+.
// Constant: ALLNEG
// Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, BACK, UP, DOWN, CENTER, ALLPOS
// Description: Vector pointing left, forwards, and down. [-1,-1,-1]
// Example(3D): Usage with `anchor`
// cuboid(20, anchor=ALLNEG);
ALLNEG = [-1, -1, -1]; // Vector pointing X-,Y-,Z-.
// Constant: CENTER // Constant: CENTER
// Aliases: CTR // Aliases: CTR
// Topics: Constants, Vectors // Topics: Constants, Vectors
// See Also: LEFT, RIGHT, FRONT, BACK, UP, DOWN, ALLNEG, ALLPOS // See Also: LEFT, RIGHT, FRONT, BACK, UP, DOWN
// Description: Zero vector. Centered. [0,0,0] // Description: Zero vector. Centered. [0,0,0]
// Example(3D): Usage with `anchor` // Example(3D): Usage with `anchor`
// cuboid(20, anchor=CENTER); // cuboid(20, anchor=CENTER);

View file

@ -302,6 +302,7 @@ module stroke(
translate(path[0]) sphere(d=width[0]); translate(path[0]) sphere(d=width[0]);
} }
} else { } else {
dummy=assert(trim1<path_length(path)-trim2, "Path is too short for endcap(s). Try a smaller width, or set endcap_length to a smaller value.");
pathcut = _path_cut_points(path, [trim1, path_length(path)-trim2], closed=false); pathcut = _path_cut_points(path, [trim1, path_length(path)-trim2], closed=false);
pathcut_su = _cut_to_seg_u_form(pathcut,path); pathcut_su = _cut_to_seg_u_form(pathcut,path);
path2 = _path_cut_getpaths(path, pathcut, closed=false)[1]; path2 = _path_cut_getpaths(path, pathcut, closed=false)[1];

View file

@ -106,7 +106,7 @@ module square(size=1, center, anchor, spin) {
// move_copies(path) color("blue") circle(d=2,$fn=8); // move_copies(path) color("blue") circle(d=2,$fn=8);
module rect(size=1, center, rounding=0, chamfer=0, anchor, spin=0) { module rect(size=1, center, rounding=0, chamfer=0, anchor, spin=0) {
size = is_num(size)? [size,size] : point2d(size); size = is_num(size)? [size,size] : point2d(size);
anchor = get_anchor(anchor, center, FRONT+LEFT, FRONT+LEFT); anchor = point2d(get_anchor(anchor, center, FRONT+LEFT, CENTER));
if (rounding==0 && chamfer==0) { if (rounding==0 && chamfer==0) {
attachable(anchor,spin, two_d=true, size=size) { attachable(anchor,spin, two_d=true, size=size) {
square(size, center=true); square(size, center=true);
@ -128,7 +128,7 @@ function rect(size=1, center, rounding=0, chamfer=0, anchor, spin=0) =
assert(is_num(rounding) || len(rounding)==4) assert(is_num(rounding) || len(rounding)==4)
let( let(
size = is_num(size)? [size,size] : point2d(size), size = is_num(size)? [size,size] : point2d(size),
anchor = point2d(get_anchor(anchor, center, FRONT+LEFT, FRONT+LEFT)), anchor = point2d(get_anchor(anchor, center, FRONT+LEFT, CENTER)),
complex = rounding!=0 || chamfer!=0 complex = rounding!=0 || chamfer!=0
) )
(rounding==0 && chamfer==0)? let( (rounding==0 && chamfer==0)? let(

View file

@ -29,7 +29,7 @@ use <builtins.scad>
// When called as a function, returns a [VNF](vnf.scad) for a cube. // When called as a function, returns a [VNF](vnf.scad) for a cube.
// Arguments: // Arguments:
// size = The size of the cube. // size = The size of the cube.
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=ALLNEG`. // center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=FRONT+LEFT+BOTTOM`.
// --- // ---
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER` // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
@ -51,7 +51,7 @@ use <builtins.scad>
// vnf_polyhedron(vnf); // vnf_polyhedron(vnf);
module cube(size=1, center, anchor, spin=0, orient=UP) module cube(size=1, center, anchor, spin=0, orient=UP)
{ {
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG); anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]);
size = scalar_vec3(size); size = scalar_vec3(size);
attachable(anchor,spin,orient, size=size) { attachable(anchor,spin,orient, size=size) {
_cube(size, center=true); _cube(size, center=true);
@ -62,7 +62,7 @@ module cube(size=1, center, anchor, spin=0, orient=UP)
function cube(size=1, center, anchor, spin=0, orient=UP) = function cube(size=1, center, anchor, spin=0, orient=UP) =
let( let(
siz = scalar_vec3(size), siz = scalar_vec3(size),
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG), anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]),
unscaled = [ unscaled = [
[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1], [-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],
[-1,-1, 1],[1,-1, 1],[1,1, 1],[-1,1, 1], [-1,-1, 1],[1,-1, 1],[1,1, 1],[-1,1, 1],
@ -110,7 +110,7 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// edges = Edges to mask. See [Specifying Edges](edges.scad#section-specifying-edges). Default: all edges. // edges = Edges to mask. See [Specifying Edges](edges.scad#section-specifying-edges). Default: all edges.
// except = Edges to explicitly NOT mask. See [Specifying Edges](edges.scad#section-specifying-edges). Default: No edges. // except = Edges to explicitly NOT mask. See [Specifying Edges](edges.scad#section-specifying-edges). Default: No edges.
// trimcorners = If true, rounds or chamfers corners where three chamfered/rounded edges meet. Default: `true` // trimcorners = If true, rounds or chamfers corners where three chamfered/rounded edges meet. Default: `true`
// p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=ALLNEG`. // p1 = Align the cuboid's corner at `p1`, if given. Forces `anchor=FRONT+LEFT+BOTTOM`.
// p2 = If given with `p1`, defines the cornerpoints of the cuboid. // p2 = If given with `p1`, defines the cornerpoints of the cuboid.
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER` // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#spin). Default: `0` // spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#spin). Default: `0`
@ -243,11 +243,11 @@ module cuboid(
if (!is_undef(p1)) { if (!is_undef(p1)) {
if (!is_undef(p2)) { if (!is_undef(p2)) {
translate(pointlist_bounds([p1,p2])[0]) { translate(pointlist_bounds([p1,p2])[0]) {
cuboid(size=v_abs(p2-p1), chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children(); cuboid(size=v_abs(p2-p1), chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=-[1,1,1]) children();
} }
} else { } else {
translate(p1) { translate(p1) {
cuboid(size=size, chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=ALLNEG) children(); cuboid(size=size, chamfer=chamfer, rounding=rounding, edges=edges, trimcorners=trimcorners, anchor=-[1,1,1]) children();
} }
} }
} else { } else {
@ -895,7 +895,7 @@ function rect_tube(
// size = [width, thickness, height] // size = [width, thickness, height]
// center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=UP`. // center = If given, overrides `anchor`. A true value sets `anchor=CENTER`, false sets `anchor=UP`.
// --- // ---
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `ALLNEG` // anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#anchor). Default: `FRONT+LEFT+BOTTOM`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0` // spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#orient). Default: `UP`
// //
@ -908,7 +908,7 @@ function rect_tube(
module wedge(size=[1, 1, 1], center, anchor, spin=0, orient=UP) module wedge(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
{ {
size = scalar_vec3(size); size = scalar_vec3(size);
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG); anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]);
vnf = wedge(size, center=true); vnf = wedge(size, center=true);
attachable(anchor,spin,orient, size=size, size2=[size.x,0], shift=[0,-size.y/2]) { attachable(anchor,spin,orient, size=size, size2=[size.x,0], shift=[0,-size.y/2]) {
if (size.z > 0) { if (size.z > 0) {
@ -922,7 +922,7 @@ module wedge(size=[1, 1, 1], center, anchor, spin=0, orient=UP)
function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) = function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) =
let( let(
size = scalar_vec3(size), size = scalar_vec3(size),
anchor = get_anchor(anchor, center, ALLNEG, ALLNEG), anchor = get_anchor(anchor, center, -[1,1,1], -[1,1,1]),
pts = [ pts = [
[ 1,1,-1], [ 1,-1,-1], [ 1,-1,1], [ 1,1,-1], [ 1,-1,-1], [ 1,-1,1],
[-1,1,-1], [-1,-1,-1], [-1,-1,1], [-1,1,-1], [-1,-1,-1], [-1,-1,1],

View file

@ -842,7 +842,7 @@ module test_centroid() {
// VNFs // VNFs
assert_approx(centroid(cube(100, center=false)), [50,50,50]); assert_approx(centroid(cube(100, center=false)), [50,50,50]);
assert_approx(centroid(cube(100, center=true)), [0,0,0]); assert_approx(centroid(cube(100, center=true)), [0,0,0]);
assert_approx(centroid(cube(100, anchor=ALLPOS)), [-50,-50,-50]); assert_approx(centroid(cube(100, anchor=[1,1,1])), [-50,-50,-50]);
assert_approx(centroid(cube(100, anchor=BOT)), [0,0,50]); assert_approx(centroid(cube(100, anchor=BOT)), [0,0,50]);
assert_approx(centroid(cube(100, anchor=TOP)), [0,0,-50]); assert_approx(centroid(cube(100, anchor=TOP)), [0,0,-50]);
assert_approx(centroid(sphere(d=100, anchor=CENTER, $fn=36)), [0,0,0]); assert_approx(centroid(sphere(d=100, anchor=CENTER, $fn=36)), [0,0,0]);

View file

@ -28,9 +28,12 @@ test_circle();
module test_rect() { module test_rect() {
assert_equal(rect(100,anchor=CENTER), [[50,-50],[-50,-50],[-50,50],[50,50]]); assert_equal(rect(100,anchor=CENTER), [[50,-50],[-50,-50],[-50,50],[50,50]]);
assert_equal(rect(100), [[100,0],[0,0],[0,100],[100,100]]); assert_equal(rect(100), [[50,-50],[-50,-50],[-50,50],[50,50]]);
assert_equal(rect([100,80]), [[100,0],[0,0],[0,80],[100,80]]); assert_equal(rect(100,center=false), [[100,0],[0,0],[0,100],[100,100]]);
assert_equal(rect([100,80],center=false), [[100,0],[0,0],[0,80],[100,80]]);
assert_equal(rect([100,80],anchor=CENTER), [[50,-40],[-50,-40],[-50,40],[50,40]]); assert_equal(rect([100,80],anchor=CENTER), [[50,-40],[-50,-40],[-50,40],[50,40]]);
assert_equal(rect([100,80]), [[50,-40],[-50,-40],[-50,40],[50,40]]);
assert_equal(rect([100,80],center=true), [[50,-40],[-50,-40],[-50,40],[50,40]]);
assert_equal(rect([100,80],anchor=FRONT+LEFT), [[100,0],[0,0],[0,80],[100,80]]); assert_equal(rect([100,80],anchor=FRONT+LEFT), [[100,0],[0,0],[0,80],[100,80]]);
assert_equal(rect([100,80],anchor=BACK+RIGHT), [[0,-80],[-100,-80],[-100,0],[0,0]]); assert_equal(rect([100,80],anchor=BACK+RIGHT), [[0,-80],[-100,-80],[-100,0],[0,0]]);
assert_approx(rect([100,80],rounding=10,anchor=CENTER,$fn=12), [[50,-30],[48.6602540378,-35],[45,-38.6602540378],[40,-40],[-40,-40],[-45,-38.6602540378],[-48.6602540378,-35],[-50,-30],[-50,30],[-48.6602540378,35],[-45,38.6602540378],[-40,40],[40,40],[45,38.6602540378],[48.6602540378,35],[50,30]]); assert_approx(rect([100,80],rounding=10,anchor=CENTER,$fn=12), [[50,-30],[48.6602540378,-35],[45,-38.6602540378],[40,-40],[-40,-40],[-45,-38.6602540378],[-48.6602540378,-35],[-50,-30],[-50,30],[-48.6602540378,35],[-45,38.6602540378],[-40,40],[40,40],[45,38.6602540378],[48.6602540378,35],[50,30]]);

View file

@ -8,7 +8,7 @@ module test_cube() {
assert_equal(cube([60,80,100],anchor=CENTER), [[[-30,-40,-50],[30,-40,-50],[30,40,-50],[-30,40,-50],[-30,-40,50],[30,-40,50],[30,40,50],[-30,40,50]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]); assert_equal(cube([60,80,100],anchor=CENTER), [[[-30,-40,-50],[30,-40,-50],[30,40,-50],[-30,40,-50],[-30,-40,50],[30,-40,50],[30,40,50],[-30,40,50]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]);
assert_equal(cube([60,80,100],center=false), [[[0,0,0],[60,0,0],[60,80,0],[0,80,0],[0,0,100],[60,0,100],[60,80,100],[0,80,100]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]); assert_equal(cube([60,80,100],center=false), [[[0,0,0],[60,0,0],[60,80,0],[0,80,0],[0,0,100],[60,0,100],[60,80,100],[0,80,100]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]);
assert_equal(cube([60,80,100]), [[[0,0,0],[60,0,0],[60,80,0],[0,80,0],[0,0,100],[60,0,100],[60,80,100],[0,80,100]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]); assert_equal(cube([60,80,100]), [[[0,0,0],[60,0,0],[60,80,0],[0,80,0],[0,0,100],[60,0,100],[60,80,100],[0,80,100]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]);
assert_equal(cube([60,80,100],anchor=ALLNEG), [[[0,0,0],[60,0,0],[60,80,0],[0,80,0],[0,0,100],[60,0,100],[60,80,100],[0,80,100]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]); assert_equal(cube([60,80,100],anchor=-[1,1,1]), [[[0,0,0],[60,0,0],[60,80,0],[0,80,0],[0,0,100],[60,0,100],[60,80,100],[0,80,100]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]);
assert_equal(cube([60,80,100],anchor=TOP), [[[-30,-40,-100],[30,-40,-100],[30,40,-100],[-30,40,-100],[-30,-40,0],[30,-40,0],[30,40,0],[-30,40,0]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]); assert_equal(cube([60,80,100],anchor=TOP), [[[-30,-40,-100],[30,-40,-100],[30,40,-100],[-30,40,-100],[-30,-40,0],[30,-40,0],[30,40,0],[-30,40,0]],[[0,1,2],[0,2,3],[0,4,5],[0,5,1],[1,5,6],[1,6,2],[2,6,7],[2,7,3],[3,7,4],[3,4,0],[6,4,7],[6,5,4]]]);
} }
test_cube(); test_cube();

View file

@ -352,12 +352,12 @@ test_all_defined();
module test_get_anchor() { module test_get_anchor() {
assert_equal(get_anchor(UP,true,ALLNEG,BOT),CENTER); assert_equal(get_anchor(UP,true,-[1,1,1],BOT),CENTER);
assert_equal(get_anchor(UP,false,ALLNEG,BOT),ALLNEG); assert_equal(get_anchor(UP,false,-[1,1,1],BOT),-[1,1,1]);
assert_equal(get_anchor(UP,undef,ALLNEG,BOT),UP); assert_equal(get_anchor(UP,undef,-[1,1,1],BOT),UP);
assert_equal(get_anchor(undef,true,ALLNEG,BOT),CENTER); assert_equal(get_anchor(undef,true,-[1,1,1],BOT),CENTER);
assert_equal(get_anchor(undef,false,ALLNEG,BOT),ALLNEG); assert_equal(get_anchor(undef,false,-[1,1,1],BOT),-[1,1,1]);
assert_equal(get_anchor(undef,undef,ALLNEG,BOT),BOT); assert_equal(get_anchor(undef,undef,-[1,1,1],BOT),BOT);
} }
test_get_anchor(); test_get_anchor();

View file

@ -418,7 +418,7 @@ function all_defined(v,recursive=false) =
// Arguments: // Arguments:
// anchor = The anchor name or vector. // anchor = The anchor name or vector.
// center = If not `undef`, this overrides the value of `anchor`. // center = If not `undef`, this overrides the value of `anchor`.
// uncentered = The value to return if `center` is not `undef` and evaluates as false. Default: ALLNEG // uncentered = The value to return if `center` is not `undef` and evaluates as false. Default: BOTTOM
// dflt = The default value to return if both `anchor` and `center` are `undef`. Default: `CENTER` // dflt = The default value to return if both `anchor` and `center` are `undef`. Default: `CENTER`
// Example: // Example:
// anchr1 = get_anchor(undef, undef, BOTTOM, TOP); // Returns: [0, 0, 1] (TOP) // anchr1 = get_anchor(undef, undef, BOTTOM, TOP); // Returns: [0, 0, 1] (TOP)