80 function _draft_layers_any_active
82 layers = _draft_get_config(
"layers-default")
121 function _draft_sheet_get_window
141 sll = _draft_get_sheet_config(ci=
"sll"),
149 zox = _draft_get_sheet_config(ci=
"zox"),
150 zoy = _draft_get_sheet_config(ci=
"zoy"),
151 zlx = _draft_get_sheet_config(ci=
"zlx"),
152 zly = _draft_get_sheet_config(ci=
"zly"),
155 ldx = sll ? sdy : sdx,
156 ldy = sll ? sdx : sdy,
170 iox = (zox > 0) ? ix : len(zlx)-1-ix
172 iox * fdx/len(zlx) -fdx/2
177 iox = (zox > 0) ? zxi : len(zlx)-1-zxi
179 iox * fdx/len(zlx) -fdx/2
184 ioy = (zoy > 0) ? iy : len(zly)-1-iy
186 ioy * fdy/len(zly) -fdy/2
191 ioy = (zoy > 0) ? zyi : len(zly)-1-zyi
193 ioy * fdy/len(zly) - fdy/2
198 [zxs, zxs + fdx/len(zlx)]
203 [zys, zys + fdy/len(zly)]
209 window_limits = [wx, wy],
212 window_coords = [ [wx[0],wy[0]], [wx[0],wy[1]], [wx[1],wy[1]], [wx[1],wy[0]] ]
214 limits ? window_limits : window_coords;
248 function _draft_sheet_get_zone
261 wl = !is_list(rx) && !is_list(ix) && !is_list(ry) && !is_list(iy) ?
263 _draft_sheet_get_window( rx=rx, ry=ry, ix=ix, iy=iy, frame=frame, limits=
true )
270 w1 = _draft_sheet_get_window( ix=
first(ix), frame=frame, limits=
true ),
271 w2 = _draft_sheet_get_window( ix=
last(ix), frame=frame, limits=
true )
273 [min(w1[0][0], w2[0][0]), max(w1[0][1], w2[0][1])]
277 w1 = _draft_sheet_get_window( rx=
first(rx), frame=frame, limits=
true ),
278 w2 = _draft_sheet_get_window( rx=
last(rx), frame=frame, limits=
true )
280 [min(w1[0][0], w2[0][0]), max(w1[0][1], w2[0][1])]
283 w1 = _draft_sheet_get_window( rx=rx, ix=ix, frame=frame, limits=
true )
291 w1 = _draft_sheet_get_window( iy=
first(iy), frame=frame, limits=
true ),
292 w2 = _draft_sheet_get_window( iy=
last(iy), frame=frame, limits=
true )
294 [min(w1[1][0], w2[1][0]), max(w1[1][1], w2[1][1])]
298 w1 = _draft_sheet_get_window( ry=
first(ry), frame=frame, limits=
true ),
299 w2 = _draft_sheet_get_window( ry=
last(ry), frame=frame, limits=
true )
301 [min(w1[1][0], w2[1][0]), max(w1[1][1], w2[1][1])]
304 w1 = _draft_sheet_get_window( ry=ry, iy=iy, frame=frame, limits=
true )
314 [wl[0][0], wl[1][0]],
315 [wl[0][0], wl[1][1]],
316 [wl[0][1], wl[1][1]],
326 cx = ( px * (wl[0][1]-wl[0][0]) + (wl[0][0]+wl[0][1]) )/2,
327 cy = ( py * (wl[1][1]-wl[1][0]) + (wl[1][0]+wl[1][1]) )/2
354 function _draft_table_get_point
377 xu = is_undef(ix) ? 0
379 :
sum([
for( i=[1:ix] ) cols[i-1]]),
385 yu = is_undef(iy) ? 0
388 : (iy == 2) ?
sum( [yt, yh] )
397 [xu*cmh*coh, yu*cmv*cov];
432 function _draft_table_get_cell
449 lv = is_undef(ix) ? [0, len(cols)]
450 : (iy <= 0) ? [0, len(cols)]
454 lh = is_undef(iy) ? [0, len(rows)+2]
460 [
for( i=[0, 1] ) _draft_table_get_point( ix=lv[i], map=map, fmap=fmap )[0] ],
461 [
for( i=[0, 1] ) _draft_table_get_point( iy=lh[i], map=map, fmap=fmap )[1] ]
470 [wl[0][0], wl[1][0]],
471 [wl[0][0], wl[1][1]],
472 [wl[0][1], wl[1][1]],
482 cx = ( px * (wl[0][1]-wl[0][0]) + (wl[0][0]+wl[0][1]) )/2,
483 cy = ( py * (wl[1][1]-wl[1][0]) + (wl[1][0]+wl[1][1]) )/2
540 module _draft_table_text
551 function erdefined_or (v, r, d) = [
for (i = r)
defined_or( v[i], d[i] )];
564 sf = is_string(text) ? [text]
569 tv = is_string(text) ? [text]
571 : is_list(text[0]) ? text[0]
575 df = erdefined_or( sf, [0:11], dfmt );
577 for ( l=[0:len(tv)-1] )
581 _draft_table_get_cell( ix=ix, iy=iy, zp=df[1], map=map, fmap=fmap )
583 + [ df[2][0], df[2][1] ] * size * df[5]
585 + df[3] * size * df[5] * l
614 function _draft_ztable_get_point
632 x = is_undef(ix) ? 0 :
sum([
for( i=[0:ix] ) vlines[i][0]]) * cmh * coh,
633 y = is_undef(iy) ? 0 :
sum([
for( i=[0:iy] ) hlines[i][0]]) * cmv * cov
668 function _draft_ztable_get_zone
682 zx = is_undef(i) ? [0, len(
map_get_value(map,
"vlines"))-1] : zones[i][0],
685 zy = is_undef(i) ? [0, len(
map_get_value(map,
"hlines"))-1] : zones[i][1],
690 [
for( i=[1, 0] ) _draft_ztable_get_point( ix=zx[i], map=map )[0] ],
691 [
for( i=[0, 1] ) _draft_ztable_get_point( iy=zy[i], map=map )[1] ]
700 [wl[0][0], wl[1][0]],
701 [wl[0][0], wl[1][1]],
702 [wl[0][1], wl[1][1]],
712 cx = ( px * (wl[0][1]-wl[0][0]) + (wl[0][0]+wl[0][1]) )/2,
713 cy = ( py * (wl[1][1]-wl[1][0]) + (wl[1][0]+wl[1][1]) )/2
769 module _draft_ztable_text
779 function erdefined_or (v, r, d) = [
for (i = r)
defined_or( v[i], d[i] )];
782 tv = is_list(text) ? text : [text];
785 df = erdefined_or( fmt, [0:11], dfmt );
787 for ( l=[0:len(tv)-1] )
791 _draft_ztable_get_zone( i=i, zp=df[1], map=map )
793 + [ df[2][0], df[2][1] ] * size * df[5]
795 + df[3] * size * df[5] * l
844 p = _draft_get_config(
"line-width-min") * w *
$draft_scale;
846 if ( _draft_get_config(
"line-use-hull") )
849 hull() { translate(i) circle(d=p); translate(t) circle(d=p); }
921 al = _draft_get_config(
"arrow-line-length-min") * s4 *
$draft_scale;
924 ca = _draft_get_config(
"arrow-angle-min") * s5;
982 xl1 =
line2d_new(m=+al/3*2, a=alx+180-ca*2, p1=pah);
983 xl2 =
line2d_new(m=-al/3*2, a=alx+180-ca*2, p1=pah);
990 xl1 =
line2d_new(m=+al/3*2, a=alx-180+ca*2, p1=pah);
991 xl2 =
line2d_new(m=-al/3*2, a=alx-180+ca*2, p1=pah);
1086 lsm = _draft_get_config(
"line-segment-min") *
$draft_scale;
1133 for (j = [1:len(mp)-2])
1156 for (i = [1:len(bp)-2])
1163 [ lp[1], xp[0], xp[1], lp[0] ]
1342 [ for( j=[0:n-1] ) [j, (j+1)%n] ];
1371 module _draft_make_3d_if_configured
1378 height=_draft_get_config(
"make-3d-height") *
$draft_scale, center=
true
x_axis2d_ul
<line-2d> A positively-directed unit line centered on the x-axis in 2d Euclidean space.
origin2d
<point-2d> The origin point coordinate in 2d Euclidean space.
y_axis3d_ul
<line-3d> A positively-directed unit line centered on the y-axis in 3d Euclidean space.
x_axis2d_uv
<vector-2d> The unit vector of the positive x-axis in 2d Euclidean space.
function binary_bit_is(v, b, t=1)
Test if a binary bit position of an integer value equals a test bit.
function line_tp(l)
Return the terminal point of a line or vector.
function angle_ll(l1, l2, s=true)
Compute the angle between two lines or vectors in a 3d or 2d-space.
function line_ip(l)
Return the initial point of a line or vector.
function line2d_new(m=1, a=0, p1=origin2d, p2, v)
Construct a 2 dimensional directed line.
function distance_pp(p1, p2)
Compute the distance between two points.
function firstn(v, n=1)
Return a list containing the first n elements of an iterable value.
function find(mv, v, c=1, i, i1=0, i2)
Find the occurrences of a match value in an iterable value.
function defined_e_or(v, i, d)
Returns an element from an iterable if it exists, or a default value if not.
function last(v)
Return the last element of an iterable value.
function exists(mv, v, s=true, i)
Check for the existence of a match value in an iterable value.
function second(v)
Return the second element of an iterable value.
function lastn(v, n=1)
Return a list containing the last n elements of an iterable value.
function first(v)
Return the first element of an iterable value.
function sequence_ns(v, n=1, s=1, w=false)
Return a list of all n-element sequential-subsets of an iterable value.
function reverse(v)
Reverse the elements of an iterable value.
function all_equal(v, cv)
Test if all elements of an iterable value equal a comparison value.
function all_strings(v)
Test if all elements of an iterable value are strings.
function index_sel(l, s=true, rs)
Selected element indices of a given list according to a selection scheme.
function merge_s(v, r=false)
Serially merge the elements of a list.
function sum(v, i1, i2)
Compute the sum of a list of numbers.
function map_get_value(m, k)
Get the map value associated with a key.
function map_get_firstof2_or(m1, m2, k, d)
Get the the first value associated with an existing key in one of two maps.
function defined_or(v, d)
Return given value, if defined, or a secondary value, if primary is not defined.
function is_defined(v)
Test if a value is defined.
function polygon_arc_sweep_p(r=1, o=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, fn, cw=true)
Compute coordinates of an arc with constant radius between two vectors in 2D.
function polygon_regular_p(n, r, a, o=origin2d, ao=0, vr, cw=true)
Compute coordinates for an n-sided regular polygon in 2D.
function polygon_line_p(p1=origin2d, p2=x_axis2d_uv, l, x, y, r, fs, ft, fn=1)
Compute coordinates along a line in 2D.
function polytope_faces2edges(f)
List the edge coordinate index pairs of a polytope.