change tex_counts to tex_reps

This commit is contained in:
Adrian Mariano 2024-01-07 20:38:53 -05:00
parent 6b4a7f3dc7
commit f8436dacc0
3 changed files with 47 additions and 25 deletions

View file

@ -1495,7 +1495,7 @@ module screw_head(screw_info,details=false, counterbore=0,flat_height,teardrop=f
[20, .165]]; [20, .165]];
intersection() { intersection() {
cyl(h=head_height/4, d=head_size, anchor=BOT) cyl(h=head_height/4, d=head_size, anchor=BOT)
attach(TOP) cyl(l=head_height*3/4, d=head_size, anchor=BOT, texture="trunc_ribs", tex_counts=[31,1], tex_scale=-lookup(adj_diam,rib_size)); attach(TOP) cyl(l=head_height*3/4, d=head_size, anchor=BOT, texture="trunc_ribs", tex_reps=[31,1], tex_scale=-lookup(adj_diam,rib_size));
cyl(h=head_height,d=head_size, chamfer2=adj_diam/10, anchor=BOT); cyl(h=head_height,d=head_size, chamfer2=adj_diam/10, anchor=BOT);
} }
} }

View file

@ -1292,9 +1292,9 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// cyl(l|h|length|height, r|d, rounding1=, rounding2=, ...); // cyl(l|h|length|height, r|d, rounding1=, rounding2=, ...);
// //
// Usage: Textured Cylinders // Usage: Textured Cylinders
// cyl(l|h|length|height, r|d, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_rot=], [tex_samples=], [style=], [tex_taper=], [tex_inset=], ...); // cyl(l|h|length|height, r|d, texture=, [tex_size=]|[tex_reps=], [tex_scale=], [tex_rot=], [tex_samples=], [style=], [tex_taper=], [tex_inset=], ...);
// cyl(l|h|length|height, r1=, r2=, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_rot=], [tex_samples=], [style=], [tex_taper=], [tex_inset=], ...); // cyl(l|h|length|height, r1=, r2=, texture=, [tex_size=]|[tex_reps=], [tex_scale=], [tex_rot=], [tex_samples=], [style=], [tex_taper=], [tex_inset=], ...);
// cyl(l|h|length|height, d1=, d2=, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_rot=], [tex_samples=], [style=], [tex_taper=], [tex_inset=], ...); // cyl(l|h|length|height, d1=, d2=, texture=, [tex_size=]|[tex_reps=], [tex_scale=], [tex_rot=], [tex_samples=], [style=], [tex_taper=], [tex_inset=], ...);
// //
// Usage: Caled as a function to get a VNF // Usage: Caled as a function to get a VNF
// vnf = cyl(...); // vnf = cyl(...);
@ -1363,7 +1363,7 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// teardrop = If given as a number, rounding around the bottom edge of the cylinder won't exceed this many degrees from vertical. If true, the limit angle is 45 degrees. Default: `false` // teardrop = If given as a number, rounding around the bottom edge of the cylinder won't exceed this many degrees from vertical. If true, the limit angle is 45 degrees. Default: `false`
// texture = A texture name string, or a rectangular array of scalar height values (0.0 to 1.0), or a VNF tile that defines the texture to apply to vertical surfaces. See {{texture()}} for what named textures are supported. // texture = A texture name string, or a rectangular array of scalar height values (0.0 to 1.0), or a VNF tile that defines the texture to apply to vertical surfaces. See {{texture()}} for what named textures are supported.
// tex_size = An optional 2D target size for the textures. Actual texture sizes will be scaled somewhat to evenly fit the available surface. Default: `[5,5]` // tex_size = An optional 2D target size for the textures. Actual texture sizes will be scaled somewhat to evenly fit the available surface. Default: `[5,5]`
// tex_counts = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height. // tex_reps = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height.
// tex_inset = If numeric, lowers the texture into the surface by that amount, before the tex_scale multiplier is applied. If `true`, insets by exactly `1`. Default: `false` // tex_inset = If numeric, lowers the texture into the surface by that amount, before the tex_scale multiplier is applied. If `true`, insets by exactly `1`. Default: `false`
// tex_rot = If true, rotates the texture 90º. // tex_rot = If true, rotates the texture 90º.
// tex_scale = Scaling multiplier for the texture depth. // tex_scale = Scaling multiplier for the texture depth.
@ -1487,7 +1487,7 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// ]; // ];
// diff() // diff()
// cyl(d=20*10/PI, h=10, chamfer=0, // cyl(d=20*10/PI, h=10, chamfer=0,
// texture=tex, tex_counts=[20,1], tex_scale=-1, // texture=tex, tex_reps=[20,1], tex_scale=-1,
// tex_taper=undef, style="concave") { // tex_taper=undef, style="concave") {
// attach([TOP,BOT]) { // attach([TOP,BOT]) {
// cyl(d1=20*10/PI, d2=30, h=5, anchor=BOT) // cyl(d1=20*10/PI, d2=30, h=5, anchor=BOT)
@ -1508,16 +1508,19 @@ function cyl(
circum=false, realign=false, shift=[0,0], circum=false, realign=false, shift=[0,0],
teardrop=false, teardrop=false,
from_end, from_end1, from_end2, from_end, from_end1, from_end2,
texture, tex_size=[5,5], tex_counts, texture, tex_size=[5,5], tex_reps, tex_counts,
tex_inset=false, tex_rot=false, tex_inset=false, tex_rot=false,
tex_scale=1, tex_samples, length, height, tex_scale=1, tex_samples, length, height,
tex_taper, style, tex_style, tex_taper, style, tex_style,
anchor, spin=0, orient=UP anchor, spin=0, orient=UP
) = ) =
assert(num_defined([style,tex_style])<2, "In cyl() the 'tex_style' parameters has been replaced by 'style'. You cannot give both.") assert(num_defined([style,tex_style])<2, "In cyl() the 'tex_style' parameters has been replaced by 'style'. You cannot give both.")
assert(num_defined([tex_reps,tex_counts])<2, "In cyl() the 'tex_counts' parameters has been replaced by 'tex_reps'. You cannot give both.")
let( let(
style = is_def(tex_style)? echo("In cyl the 'tex_style()' parameters is deprecated and has been replaced by 'style'")tex_style style = is_def(tex_style)? echo("In cyl() the 'tex_style' parameter is deprecated and has been replaced by 'style'")tex_style
: default(style,"min_edge"), : default(style,"min_edge"),
tex_reps = is_def(tex_counts)? echo("In cyl() the 'tex_counts' parameter is deprecated and has been replaced by 'tex_reps'")tex_counts
: tex_reps,
l = one_defined([l, h, length, height],"l,h,length,height",dflt=1), l = one_defined([l, h, length, height],"l,h,length,height",dflt=1),
_r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1), _r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1),
_r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1), _r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1),
@ -1620,7 +1623,7 @@ function cyl(
if (texture==undef) [0,l/2], if (texture==undef) [0,l/2],
] ]
) rotate_sweep(path, ) rotate_sweep(path,
texture=texture, tex_counts=tex_counts, tex_size=tex_size, texture=texture, tex_reps=tex_reps, tex_size=tex_size,
tex_inset=tex_inset, tex_rot=tex_rot, tex_inset=tex_inset, tex_rot=tex_rot,
tex_scale=tex_scale, tex_samples=tex_samples, tex_scale=tex_scale, tex_samples=tex_samples,
tex_taper=tex_taper, style=style, closed=false tex_taper=tex_taper, style=style, closed=false
@ -1663,14 +1666,19 @@ module cyl(
circum=false, realign=false, shift=[0,0], circum=false, realign=false, shift=[0,0],
teardrop=false, teardrop=false,
from_end, from_end1, from_end2, from_end, from_end1, from_end2,
texture, tex_size=[5,5], tex_counts, texture, tex_size=[5,5], tex_reps, tex_counts,
tex_inset=false, tex_rot=false, tex_inset=false, tex_rot=false,
tex_scale=1, tex_samples, length, height, tex_scale=1, tex_samples, length, height,
tex_taper, style, tex_style, tex_taper, style, tex_style,
anchor, spin=0, orient=UP anchor, spin=0, orient=UP
) { ) {
dummy=
assert(num_defined([style,tex_style])<2, "In cyl() the 'tex_style' parameters has been replaced by 'style'. You cannot give both.")
assert(num_defined([tex_reps,tex_counts])<2, "In cyl() the 'tex_counts' parameters has been replaced by 'tex_reps'. You cannot give both.");
style = is_def(tex_style)? echo("In cyl the 'tex_style()' parameters is deprecated and has been replaced by 'style'")tex_style style = is_def(tex_style)? echo("In cyl the 'tex_style()' parameters is deprecated and has been replaced by 'style'")tex_style
: default(style,"min_edge"); : default(style,"min_edge");
tex_reps = is_def(tex_counts)? echo("In cyl() the 'tex_counts' parameter is deprecated and has been replaced by 'tex_reps'")tex_counts
: tex_reps;
l = one_defined([l, h, length, height],"l,h,length,height",dflt=1); l = one_defined([l, h, length, height],"l,h,length,height",dflt=1);
_r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1); _r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=1);
_r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1); _r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=1);
@ -1695,7 +1703,7 @@ module cyl(
from_end=from_end, from_end1=from_end1, from_end2=from_end2, from_end=from_end, from_end1=from_end1, from_end2=from_end2,
teardrop=teardrop, teardrop=teardrop,
texture=texture, tex_size=tex_size, texture=texture, tex_size=tex_size,
tex_counts=tex_counts, tex_scale=tex_scale, tex_reps=tex_reps, tex_scale=tex_scale,
tex_inset=tex_inset, tex_rot=tex_rot, tex_inset=tex_inset, tex_rot=tex_rot,
style=style, tex_taper=tex_taper, style=style, tex_taper=tex_taper,
tex_samples=tex_samples tex_samples=tex_samples

View file

@ -517,10 +517,10 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
// Usage: As Module // Usage: As Module
// linear_sweep(region, [height], [center=], [slices=], [twist=], [scale=], [style=], [caps=], [convexity=]) [ATTACHMENTS]; // linear_sweep(region, [height], [center=], [slices=], [twist=], [scale=], [style=], [caps=], [convexity=]) [ATTACHMENTS];
// Usage: With Texturing // Usage: With Texturing
// linear_sweep(region, [height], [center=], texture=, [tex_size=]|[tex_counts=], [tex_scale=], [style=], [tex_samples=], ...) [ATTACHMENTS]; // linear_sweep(region, [height], [center=], texture=, [tex_size=]|[tex_reps=], [tex_scale=], [style=], [tex_samples=], ...) [ATTACHMENTS];
// Usage: As Function // Usage: As Function
// vnf = linear_sweep(region, [height], [center=], [slices=], [twist=], [scale=], [style=], [caps=]); // vnf = linear_sweep(region, [height], [center=], [slices=], [twist=], [scale=], [style=], [caps=]);
// vnf = linear_sweep(region, [height], [center=], texture=, [tex_size=]|[tex_counts=], [tex_scale=], [style=], [tex_samples=], ...); // vnf = linear_sweep(region, [height], [center=], texture=, [tex_size=]|[tex_reps=], [tex_scale=], [style=], [tex_samples=], ...);
// Description: // Description:
// If called as a module, creates a polyhedron that is the linear extrusion of the given 2D region or polygon. // If called as a module, creates a polyhedron that is the linear extrusion of the given 2D region or polygon.
// If called as a function, returns a VNF that can be used to generate a polyhedron of the linear extrusion // If called as a function, returns a VNF that can be used to generate a polyhedron of the linear extrusion
@ -545,7 +545,7 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
// maxseg = If given, then any long segments of the region will be subdivided to be shorter than this length. This can refine twisting flat faces a lot. Default: `undef` (no subsampling) // maxseg = If given, then any long segments of the region will be subdivided to be shorter than this length. This can refine twisting flat faces a lot. Default: `undef` (no subsampling)
// texture = A texture name string, or a rectangular array of scalar height values (0.0 to 1.0), or a VNF tile that defines the texture to apply to vertical surfaces. See {{texture()}} for what named textures are supported. // texture = A texture name string, or a rectangular array of scalar height values (0.0 to 1.0), or a VNF tile that defines the texture to apply to vertical surfaces. See {{texture()}} for what named textures are supported.
// tex_size = An optional 2D target size for the textures. Actual texture sizes will be scaled somewhat to evenly fit the available surface. Default: `[5,5]` // tex_size = An optional 2D target size for the textures. Actual texture sizes will be scaled somewhat to evenly fit the available surface. Default: `[5,5]`
// tex_counts = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height. // tex_reps = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height.
// tex_inset = If numeric, lowers the texture into the surface by that amount, before the tex_scale multiplier is applied. If `true`, insets by exactly `1`. Default: `false` // tex_inset = If numeric, lowers the texture into the surface by that amount, before the tex_scale multiplier is applied. If `true`, insets by exactly `1`. Default: `false`
// tex_rot = If true, rotates the texture 90º. // tex_rot = If true, rotates the texture 90º.
// tex_scale = Scaling multiplier for the texture depth. // tex_scale = Scaling multiplier for the texture depth.
@ -707,7 +707,7 @@ module linear_sweep(
region, height, center, region, height, center,
twist=0, scale=1, shift=[0,0], twist=0, scale=1, shift=[0,0],
slices, maxseg, style="default", convexity, caps=true, slices, maxseg, style="default", convexity, caps=true,
texture, tex_size=[5,5], tex_counts, texture, tex_size=[5,5], tex_reps, tex_counts,
tex_inset=false, tex_rot=false, tex_inset=false, tex_rot=false,
tex_scale=1, tex_samples, tex_scale=1, tex_samples,
cp, atype="hull", h,l,length, cp, atype="hull", h,l,length,
@ -724,6 +724,7 @@ module linear_sweep(
twist=twist, scale=scale, shift=shift, twist=twist, scale=scale, shift=shift,
texture=texture, texture=texture,
tex_size=tex_size, tex_size=tex_size,
tex_reps=tex_reps,
tex_counts=tex_counts, tex_counts=tex_counts,
tex_inset=tex_inset, tex_inset=tex_inset,
tex_rot=tex_rot, tex_rot=tex_rot,
@ -759,12 +760,17 @@ function linear_sweep(
twist=0, scale=1, shift=[0,0], twist=0, scale=1, shift=[0,0],
slices, maxseg, style="default", caps=true, slices, maxseg, style="default", caps=true,
cp, atype="hull", h, cp, atype="hull", h,
texture, tex_size=[5,5], tex_counts, texture, tex_size=[5,5], tex_reps, tex_counts,
tex_inset=false, tex_rot=false, tex_inset=false, tex_rot=false,
tex_scale=1, tex_samples, h, l, length, tex_scale=1, tex_samples, h, l, length,
anchor, spin=0, orient=UP anchor, spin=0, orient=UP
) = ) =
let( region = force_region(region) ) assert(num_defined([tex_reps,tex_counts])<2, "In linear_sweep() the 'tex_counts' parameters has been replaced by 'tex_reps'. You cannot give both.")
let(
region = force_region(region),
tex_reps = is_def(tex_counts)? echo("In cyl() the 'tex_counts' parameter is deprecated and has been replaced by 'tex_reps'")tex_counts
: tex_reps
)
assert(is_region(region), "Input is not a region or polygon.") assert(is_region(region), "Input is not a region or polygon.")
assert(is_num(scale) || is_vector(scale)) assert(is_num(scale) || is_vector(scale))
assert(is_vector(shift, 2), str(shift)) assert(is_vector(shift, 2), str(shift))
@ -775,7 +781,7 @@ function linear_sweep(
!is_undef(texture)? _textured_linear_sweep( !is_undef(texture)? _textured_linear_sweep(
region, h=h, caps=caps, region, h=h, caps=caps,
texture=texture, tex_size=tex_size, texture=texture, tex_size=tex_size,
counts=tex_counts, inset=tex_inset, counts=tex_reps, inset=tex_inset,
rot=tex_rot, tex_scale=tex_scale, rot=tex_rot, tex_scale=tex_scale,
twist=twist, scale=scale, shift=shift, twist=twist, scale=scale, shift=shift,
style=style, samples=tex_samples, style=style, samples=tex_samples,
@ -851,7 +857,7 @@ function linear_sweep(
// Usage: As Module // Usage: As Module
// rotate_sweep(shape, [angle], ...) [ATTACHMENTS]; // rotate_sweep(shape, [angle], ...) [ATTACHMENTS];
// Usage: With Texturing // Usage: With Texturing
// rotate_sweep(shape, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_samples=], [tex_rot=], [tex_inset=], ...) [ATTACHMENTS]; // rotate_sweep(shape, texture=, [tex_size=]|[tex_reps=], [tex_scale=], [tex_samples=], [tex_rot=], [tex_inset=], ...) [ATTACHMENTS];
// Description: // Description:
// Takes a polygon or [region](regions.scad) and sweeps it in a rotation around the Z axis, with optional texturing. // Takes a polygon or [region](regions.scad) and sweeps it in a rotation around the Z axis, with optional texturing.
// When called as a function, returns a [VNF](vnf.scad). // When called as a function, returns a [VNF](vnf.scad).
@ -862,7 +868,7 @@ function linear_sweep(
// --- // ---
// texture = A texture name string, or a rectangular array of scalar height values (0.0 to 1.0), or a VNF tile that defines the texture to apply to vertical surfaces. See {{texture()}} for what named textures are supported. // texture = A texture name string, or a rectangular array of scalar height values (0.0 to 1.0), or a VNF tile that defines the texture to apply to vertical surfaces. See {{texture()}} for what named textures are supported.
// tex_size = An optional 2D target size for the textures. Actual texture sizes will be scaled somewhat to evenly fit the available surface. Default: `[5,5]` // tex_size = An optional 2D target size for the textures. Actual texture sizes will be scaled somewhat to evenly fit the available surface. Default: `[5,5]`
// tex_counts = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height. // tex_reps = If given instead of tex_size, gives the tile repetition counts for textures over the surface length and height.
// tex_inset = If numeric, lowers the texture into the surface by that amount, before the tex_scale multiplier is applied. If `true`, insets by exactly `1`. Default: `false` // tex_inset = If numeric, lowers the texture into the surface by that amount, before the tex_scale multiplier is applied. If `true`, insets by exactly `1`. Default: `false`
// tex_rot = If true, rotates the texture 90º. // tex_rot = If true, rotates the texture 90º.
// tex_scale = Scaling multiplier for the texture depth. // tex_scale = Scaling multiplier for the texture depth.
@ -951,7 +957,7 @@ function linear_sweep(
function rotate_sweep( function rotate_sweep(
shape, angle=360, shape, angle=360,
texture, tex_size=[5,5], tex_counts, texture, tex_size=[5,5], tex_counts, tex_reps,
tex_inset=false, tex_rot=false, tex_inset=false, tex_rot=false,
tex_scale=1, tex_samples, tex_scale=1, tex_samples,
tex_taper, shift=[0,0], closed=true, tex_taper, shift=[0,0], closed=true,
@ -959,7 +965,11 @@ function rotate_sweep(
atype="hull", anchor="origin", atype="hull", anchor="origin",
spin=0, orient=UP spin=0, orient=UP
) = ) =
let( region = force_region(shape) ) assert(num_defined([tex_reps,tex_counts])<2, "In rotate_sweep() the 'tex_counts' parameters has been replaced by 'tex_reps'. You cannot give both.")
let( region = force_region(shape),
tex_reps = is_def(tex_counts)? echo("In rotate_sweep() the 'tex_counts' parameter is deprecated and has been replaced by 'tex_reps'")tex_counts
: tex_reps
)
assert(is_region(region), "Input is not a region or polygon.") assert(is_region(region), "Input is not a region or polygon.")
let( let(
bounds = pointlist_bounds(flatten(region)), bounds = pointlist_bounds(flatten(region)),
@ -974,7 +984,7 @@ function rotate_sweep(
shape, shape,
texture=texture, texture=texture,
tex_size=tex_size, tex_size=tex_size,
counts=tex_counts, counts=tex_reps,
tex_scale=tex_scale, tex_scale=tex_scale,
inset=tex_inset, inset=tex_inset,
rot=tex_rot, rot=tex_rot,
@ -1005,7 +1015,7 @@ function rotate_sweep(
module rotate_sweep( module rotate_sweep(
shape, angle=360, shape, angle=360,
texture, tex_size=[5,5], tex_counts, texture, tex_size=[5,5], tex_counts, tex_reps,
tex_inset=false, tex_rot=false, tex_inset=false, tex_rot=false,
tex_scale=1, tex_samples, tex_scale=1, tex_samples,
tex_taper, shift=[0,0], tex_taper, shift=[0,0],
@ -1018,6 +1028,10 @@ module rotate_sweep(
spin=0, spin=0,
orient=UP orient=UP
) { ) {
dummy =
assert(num_defined([tex_reps,tex_counts])<2, "In rotate_sweep() the 'tex_counts' parameters has been replaced by 'tex_reps'. You cannot give both.");
tex_reps = is_def(tex_counts)? echo("In rotate_sweep() the 'tex_counts' parameter is deprecated and has been replaced by 'tex_reps'")tex_counts
: tex_reps;
region = force_region(shape); region = force_region(shape);
check = assert(is_region(region), "Input is not a region or polygon."); check = assert(is_region(region), "Input is not a region or polygon.");
bounds = pointlist_bounds(flatten(region)); bounds = pointlist_bounds(flatten(region));
@ -1032,7 +1046,7 @@ module rotate_sweep(
shape, shape,
texture=texture, texture=texture,
tex_size=tex_size, tex_size=tex_size,
counts=tex_counts, counts=tex_reps,
tex_scale=tex_scale, tex_scale=tex_scale,
inset=tex_inset, inset=tex_inset,
rot=tex_rot, rot=tex_rot,