color.scad usage fix

This commit is contained in:
Adrian Mariano 2022-03-30 20:08:15 -04:00
parent ce87d630ba
commit ec3c0a3c62

View file

@ -15,7 +15,7 @@ use <builtins.scad>
// Module: recolor() // Module: recolor()
// Usage: // Usage:
// recolor([c]) {...} // recolor([c]) children;
// Topics: Attachments // Topics: Attachments
// See Also: color_this() // See Also: color_this()
// Description: // Description:
@ -34,6 +34,7 @@ use <builtins.scad>
// attach(TOP,BOT) cuboid([4,4,2]); // attach(TOP,BOT) cuboid([4,4,2]);
module recolor(c="default") module recolor(c="default")
{ {
req_children($children);
$color=c; $color=c;
children(); children();
} }
@ -41,7 +42,7 @@ module recolor(c="default")
// Module: color_this() // Module: color_this()
// Usage: // Usage:
// color_this([c]) {...} // color_this([c]) children;
// Topics: Attachments // Topics: Attachments
// See Also: recolor() // See Also: recolor()
// Description: // Description:
@ -61,6 +62,7 @@ module recolor(c="default")
// attach(TOP,BOT) cuboid([4,4,2]); // attach(TOP,BOT) cuboid([4,4,2]);
module color_this(c="default") module color_this(c="default")
{ {
req_children($children);
$save_color=default($color,"default"); $save_color=default($color,"default");
$color=c; $color=c;
children(); children();
@ -69,7 +71,7 @@ module color_this(c="default")
// Module: rainbow() // Module: rainbow()
// Usage: // Usage:
// rainbow(list) ... // rainbow(list,[stride],[maxhues],[shuffle],[seed]) children;
// Description: // Description:
// Iterates the list, displaying children in different colors for each list item. The color // Iterates the list, displaying children in different colors for each list item. The color
// is set using the color() module, so this module is not compatible with {{recolor()}} or // is set using the color() module, so this module is not compatible with {{recolor()}} or
@ -91,6 +93,7 @@ module color_this(c="default")
// rainbow(rgn) stroke($item, closed=true); // rainbow(rgn) stroke($item, closed=true);
module rainbow(list, stride=1, maxhues, shuffle=false, seed) module rainbow(list, stride=1, maxhues, shuffle=false, seed)
{ {
req_children($children);
ll = len(list); ll = len(list);
maxhues = first_defined([maxhues,ll]); maxhues = first_defined([maxhues,ll]);
huestep = 360 / maxhues; huestep = 360 / maxhues;
@ -107,7 +110,7 @@ module rainbow(list, stride=1, maxhues, shuffle=false, seed)
// Function&Module: hsl() // Function&Module: hsl()
// Usage: // Usage:
// hsl(h,[s],[l],[a]) ... // hsl(h,[s],[l],[a]) children;
// rgb = hsl(h,[s],[l],[a]); // rgb = hsl(h,[s],[l],[a]);
// Description: // Description:
// When called as a function, returns the [R,G,B] color for the given hue `h`, saturation `s`, and lightness `l` from the HSL colorspace. If you supply // When called as a function, returns the [R,G,B] color for the given hue `h`, saturation `s`, and lightness `l` from the HSL colorspace. If you supply
@ -133,12 +136,16 @@ function hsl(h,s=1,l=0.5,a) =
if (is_def(a)) a if (is_def(a)) a
]; ];
module hsl(h,s=1,l=0.5,a=1) color(hsl(h,s,l),a) children(); module hsl(h,s=1,l=0.5,a=1)
{
req_children($children);
color(hsl(h,s,l),a) children();
}
// Function&Module: hsv() // Function&Module: hsv()
// Usage: // Usage:
// hsv(h,[s],[v],[a]) ... // hsv(h,[s],[v],[a]) children;
// rgb = hsv(h,[s],[v],[a]); // rgb = hsv(h,[s],[v],[a]);
// Description: // Description:
// When called as a function, returns the [R,G,B] color for the given hue `h`, saturation `s`, and value `v` from the HSV colorspace. If you supply // When called as a function, returns the [R,G,B] color for the given hue `h`, saturation `s`, and value `v` from the HSV colorspace. If you supply
@ -175,7 +182,11 @@ function hsv(h,s=1,v=1,a) =
is_def(a) ? point4d(add_scalar(rgbprime,m),a) is_def(a) ? point4d(add_scalar(rgbprime,m),a)
: add_scalar(rgbprime,m); : add_scalar(rgbprime,m);
module hsv(h,s=1,v=1,a=1) color(hsv(h,s,v),a) children(); module hsv(h,s=1,v=1,a=1)
{
req_children($children);
color(hsv(h,s,v),a) children();
}