mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added mutator.scad mutators.
This commit is contained in:
parent
794741f824
commit
1a7bfb687f
2 changed files with 51 additions and 1 deletions
50
tests/test_mutators.scad
Normal file
50
tests/test_mutators.scad
Normal file
|
@ -0,0 +1,50 @@
|
|||
include <BOSL2/std.scad>
|
||||
|
||||
|
||||
module test_HSL() {
|
||||
for (h = [0:30:360]) {
|
||||
for (s = [0:0.2:1]) {
|
||||
for (l = [0:0.2:1]) {
|
||||
c = (1 - abs(2*l-1)) * s;
|
||||
x = c * (1 - abs(((h/60)%2)-1));
|
||||
m = l - c/2;
|
||||
rgb = [m,m,m] + (
|
||||
h<= 60? [c,x,0] :
|
||||
h<=120? [x,c,0] :
|
||||
h<=180? [0,c,x] :
|
||||
h<=240? [0,x,c] :
|
||||
h<=300? [x,0,c] :
|
||||
[c,0,x]
|
||||
);
|
||||
assert_approx(HSL(h,s,l), rgb, str_format("h={}, s={}, l={}", [h,s,l]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
test_HSL();
|
||||
|
||||
|
||||
module test_HSV() {
|
||||
for (h = [0:30:360]) {
|
||||
for (s = [0:0.2:1]) {
|
||||
for (v = [0:0.2:1]) {
|
||||
c = v * s;
|
||||
x = c * (1 - abs(((h/60)%2)-1));
|
||||
m = v - c;
|
||||
rgb = [m,m,m] + (
|
||||
h<= 60? [c,x,0] :
|
||||
h<=120? [x,c,0] :
|
||||
h<=180? [0,c,x] :
|
||||
h<=240? [0,x,c] :
|
||||
h<=300? [x,0,c] :
|
||||
[c,0,x]
|
||||
);
|
||||
assert_approx(HSV(h,s,v), rgb, str_format("h={}, s={}, v={}", [h,s,v]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
test_HSV();
|
||||
|
||||
|
||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,364];
|
||||
BOSL_VERSION = [2,0,366];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue