From 1a7bfb687f41a685c31e5c886ba708e08653e303 Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Mon, 22 Jun 2020 22:34:36 -0700 Subject: [PATCH] Added mutator.scad mutators. --- tests/test_mutators.scad | 50 ++++++++++++++++++++++++++++++++++++++++ version.scad | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/test_mutators.scad diff --git a/tests/test_mutators.scad b/tests/test_mutators.scad new file mode 100644 index 0000000..5854b52 --- /dev/null +++ b/tests/test_mutators.scad @@ -0,0 +1,50 @@ +include + + +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 diff --git a/version.scad b/version.scad index 4692c01..1637ac0 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,364]; +BOSL_VERSION = [2,0,366]; // Section: BOSL Library Version Functions