From 422ca55b60bf029349476312f4bebf7709aea397 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 18 Oct 2018 06:57:26 -0400 Subject: - Added "Alpha" abstraction. - Added "Pigment" abstraction. --- stdlib/source/lux/data/color.lux | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 55624f29e..c242a48ad 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -1,7 +1,9 @@ (.module: [lux #* - [control ["eq" equivalence]] + [control + ["eq" equivalence]] [data + [number ("rev/." Interval)] [collection ["." list ("list/." Functor)]]] ["." math] @@ -28,9 +30,9 @@ (def: #export (color [red green blue]) (-> [Nat Nat Nat] Color) - (:abstraction [(n/% rgb red) - (n/% rgb green) - (n/% rgb blue)])) + (:abstraction {#red (n/% rgb red) + #green (n/% rgb green) + #blue (n/% rgb blue)})) (def: #export to-rgb (-> Color [Nat Nat Nat]) @@ -216,8 +218,8 @@ (interpolate' greenE greenS) (interpolate' blueE blueS)]))) -(def: black Color (color [0 0 0])) -(def: white Color (color [top top top])) +(def: #export black Color (color [0 0 0])) +(def: #export white Color (color [top top top])) (do-template [ ] [(def: #export ( ratio color) @@ -306,3 +308,21 @@ normalize [hue saturation] from-hsb)))))) + +(type: #export Alpha Rev) + +(def: #export transparent + Alpha + rev/bottom) + +(def: #export translucent + Alpha + .5) + +(def: #export opaque + Alpha + rev/top) + +(type: #export Pigment + {#color Color + #alpha Alpha}) -- cgit v1.2.3