mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-09 21:16:47 +02:00
Added stride= to rainbow()
This commit is contained in:
@@ -2373,6 +2373,7 @@ module HSV(h,s=1,v=1,a=1) color(HSV(h,s,v),a) children();
|
|||||||
// This is useful for debugging lists of paths and such.
|
// This is useful for debugging lists of paths and such.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// list = The list of items to iterate through.
|
// list = The list of items to iterate through.
|
||||||
|
// stride = Consecutive colors stride around the color wheel divided into this many parts.
|
||||||
// Side Effects:
|
// Side Effects:
|
||||||
// Sets the color to progressive values along the ROYGBIV spectrum for each item.
|
// Sets the color to progressive values along the ROYGBIV spectrum for each item.
|
||||||
// Sets `$idx` to the index of the current item in `list` that we want to show.
|
// Sets `$idx` to the index of the current item in `list` that we want to show.
|
||||||
@@ -2382,10 +2383,16 @@ module HSV(h,s=1,v=1,a=1) color(HSV(h,s,v),a) children();
|
|||||||
// Example(2D):
|
// Example(2D):
|
||||||
// rgn = [circle(d=45,$fn=3), circle(d=75,$fn=4), circle(d=50)];
|
// rgn = [circle(d=45,$fn=3), circle(d=75,$fn=4), circle(d=50)];
|
||||||
// rainbow(rgn) stroke($item, closed=true);
|
// rainbow(rgn) stroke($item, closed=true);
|
||||||
module rainbow(list)
|
module rainbow(list, stride=1)
|
||||||
for($idx=idx(list),$item=[list[$idx]])
|
{
|
||||||
HSV(h=360*$idx/len(list))
|
ll = len(list);
|
||||||
children();
|
huestep = 360 / ll;
|
||||||
|
hues = [for (i=[0:1:ll-1]) posmod(i*huestep+i*360/stride,360)];
|
||||||
|
for($idx=idx(list)) {
|
||||||
|
$item = list[$idx];
|
||||||
|
HSV(h=hues[$idx]) children();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
Reference in New Issue
Block a user