From f8436dacc01ba3e088e3b3e5cb571296b218f846 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Sun, 7 Jan 2024 20:38:53 -0500 Subject: [PATCH] change tex_counts to tex_reps --- screws.scad | 2 +- shapes3d.scad | 28 ++++++++++++++++++---------- skin.scad | 42 ++++++++++++++++++++++++++++-------------- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/screws.scad b/screws.scad index 089eec5..0c2e317 100644 --- a/screws.scad +++ b/screws.scad @@ -1495,7 +1495,7 @@ module screw_head(screw_info,details=false, counterbore=0,flat_height,teardrop=f [20, .165]]; intersection() { 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); } } diff --git a/shapes3d.scad b/shapes3d.scad index d225746..93cf8d8 100644 --- a/shapes3d.scad +++ b/shapes3d.scad @@ -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=, ...); // // 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, r1=, r2=, 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_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_reps=], [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 // 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` // 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_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_rot = If true, rotates the texture 90º. // 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() // 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") { // attach([TOP,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], teardrop=false, 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_scale=1, tex_samples, length, height, tex_taper, style, tex_style, 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([tex_reps,tex_counts])<2, "In cyl() the 'tex_counts' parameters has been replaced by 'tex_reps'. You cannot give both.") 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"), + 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), _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), @@ -1620,7 +1623,7 @@ function cyl( if (texture==undef) [0,l/2], ] ) 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_scale=tex_scale, tex_samples=tex_samples, tex_taper=tex_taper, style=style, closed=false @@ -1663,14 +1666,19 @@ module cyl( circum=false, realign=false, shift=[0,0], teardrop=false, 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_scale=1, tex_samples, length, height, tex_taper, style, tex_style, 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 : 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); _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); @@ -1695,7 +1703,7 @@ module cyl( from_end=from_end, from_end1=from_end1, from_end2=from_end2, teardrop=teardrop, 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, style=style, tex_taper=tex_taper, tex_samples=tex_samples diff --git a/skin.scad b/skin.scad index 9d4efba..024f5f2 100644 --- a/skin.scad +++ b/skin.scad @@ -517,10 +517,10 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close // Usage: As Module // linear_sweep(region, [height], [center=], [slices=], [twist=], [scale=], [style=], [caps=], [convexity=]) [ATTACHMENTS]; // 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 // 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: // 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 @@ -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) // 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_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_rot = If true, rotates the texture 90º. // tex_scale = Scaling multiplier for the texture depth. @@ -707,7 +707,7 @@ module linear_sweep( region, height, center, twist=0, scale=1, shift=[0,0], 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_scale=1, tex_samples, cp, atype="hull", h,l,length, @@ -724,6 +724,7 @@ module linear_sweep( twist=twist, scale=scale, shift=shift, texture=texture, tex_size=tex_size, + tex_reps=tex_reps, tex_counts=tex_counts, tex_inset=tex_inset, tex_rot=tex_rot, @@ -759,12 +760,17 @@ function linear_sweep( twist=0, scale=1, shift=[0,0], slices, maxseg, style="default", caps=true, 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_scale=1, tex_samples, h, l, length, 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_num(scale) || is_vector(scale)) assert(is_vector(shift, 2), str(shift)) @@ -775,7 +781,7 @@ function linear_sweep( !is_undef(texture)? _textured_linear_sweep( region, h=h, caps=caps, 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, twist=twist, scale=scale, shift=shift, style=style, samples=tex_samples, @@ -851,7 +857,7 @@ function linear_sweep( // Usage: As Module // rotate_sweep(shape, [angle], ...) [ATTACHMENTS]; // 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: // 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). @@ -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. // 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_rot = If true, rotates the texture 90º. // tex_scale = Scaling multiplier for the texture depth. @@ -951,7 +957,7 @@ function linear_sweep( function rotate_sweep( 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_scale=1, tex_samples, tex_taper, shift=[0,0], closed=true, @@ -959,7 +965,11 @@ function rotate_sweep( atype="hull", anchor="origin", 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.") let( bounds = pointlist_bounds(flatten(region)), @@ -974,7 +984,7 @@ function rotate_sweep( shape, texture=texture, tex_size=tex_size, - counts=tex_counts, + counts=tex_reps, tex_scale=tex_scale, inset=tex_inset, rot=tex_rot, @@ -1005,7 +1015,7 @@ function rotate_sweep( module rotate_sweep( 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_scale=1, tex_samples, tex_taper, shift=[0,0], @@ -1018,6 +1028,10 @@ module rotate_sweep( spin=0, 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); check = assert(is_region(region), "Input is not a region or polygon."); bounds = pointlist_bounds(flatten(region)); @@ -1032,7 +1046,7 @@ module rotate_sweep( shape, texture=texture, tex_size=tex_size, - counts=tex_counts, + counts=tex_reps, tex_scale=tex_scale, inset=tex_inset, rot=tex_rot,