diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/data/color.lux | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 433dd9bc3..f99dbfbd9 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -41,43 +41,43 @@ (-> Frac Nat) (|>> (f.* rgb_factor) f.int .nat)) -(type: #export RGB +(type: .public RGB {#.doc (doc "Red-Green-Blue color format.")} {#red Nat #green Nat #blue Nat}) -(type: #export HSL +(type: .public HSL {#.doc (doc "Hue-Saturation-Lightness color format.")} [Frac Frac Frac]) -(type: #export CMYK +(type: .public CMYK {#.doc (doc "Cyan-Magenta-Yellow-Key color format.")} {#cyan Frac #magenta Frac #yellow Frac #key Frac}) -(type: #export HSB +(type: .public HSB {#.doc (doc "Hue-Saturation-Brightness color format.")} [Frac Frac Frac]) -(abstract: #export Color - RGB - +(abstract: .public Color {#.doc (doc "A color value, independent of color format.")} - (def: #export (of_rgb [red green blue]) + RGB + + (def: .public (of_rgb [red green blue]) (-> RGB Color) (:abstraction {#red (n.% ..rgb_limit red) #green (n.% ..rgb_limit green) #blue (n.% ..rgb_limit blue)})) - (def: #export rgb + (def: .public rgb (-> Color RGB) (|>> :representation)) - (implementation: #export equivalence + (implementation: .public equivalence (Equivalence Color) (def: (= reference sample) @@ -87,7 +87,7 @@ (n.= gR gS) (n.= bR bS))))) - (implementation: #export hash + (implementation: .public hash (Hash Color) (def: &equivalence ..equivalence) @@ -99,19 +99,19 @@ (i64.left_shifted 8 g) b)))) - (def: #export black + (def: .public black Color (..of_rgb {#red 0 #green 0 #blue 0})) - (def: #export white + (def: .public white Color (..of_rgb {#red ..top #green ..top #blue ..top})) - (implementation: #export addition + (implementation: .public addition (Monoid Color) (def: identity ..black) @@ -127,7 +127,7 @@ (-> Nat Nat) (|> ..top (n.- value))) - (def: #export (complement color) + (def: .public (complement color) {#.doc (doc "The opposite color.")} (-> Color Color) (let [[red green blue] (:representation color)] @@ -135,7 +135,7 @@ #green (complement' green) #blue (complement' blue)}))) - (implementation: #export subtraction + (implementation: .public subtraction (Monoid Color) (def: identity ..white) @@ -148,7 +148,7 @@ #blue (n.min lB rB)})))) ) -(def: #export (hsl color) +(def: .public (hsl color) (-> Color HSL) (let [[red green blue] (rgb color) red (..down red) @@ -202,7 +202,7 @@ ## else p)))) -(def: #export (of_hsl [hue saturation luminance]) +(def: .public (of_hsl [hue saturation luminance]) (-> HSL Color) (if (f.= +0.0 saturation) ## Achromatic @@ -220,7 +220,7 @@ #green (|> hue (hue_rgb p q)) #blue (|> hue (f.- third) (hue_rgb p q))})))) -(def: #export (hsb color) +(def: .public (hsb color) (-> Color HSB) (let [[red green blue] (rgb color) red (..down red) @@ -252,7 +252,7 @@ saturation brightness])))) -(def: #export (of_hsb [hue saturation brightness]) +(def: .public (of_hsb [hue saturation brightness]) (-> HSB Color) (let [hue (|> hue (f.* +6.0)) i (math.floor hue) @@ -269,7 +269,7 @@ #green (..up green) #blue (..up blue)}))) -(def: #export (cmyk color) +(def: .public (cmyk color) (-> Color CMYK) (let [[red green blue] (rgb color) red (..down red) @@ -287,7 +287,7 @@ #yellow yellow #key key})) -(def: #export (of_cmyk [cyan magenta yellow key]) +(def: .public (of_cmyk [cyan magenta yellow key]) (-> CMYK Color) (if (f.= +1.0 key) (of_rgb {#red 0 @@ -314,7 +314,7 @@ ## else ratio)) -(def: #export (interpolated ratio end start) +(def: .public (interpolated ratio end start) (-> Frac Color Color Color) (let [dS (..normal ratio) dE (|> +1.0 (f.- dS)) @@ -331,7 +331,7 @@ #blue (interpolated' blueE blueS)}))) (template [<name> <target>] - [(def: #export (<name> ratio color) + [(def: .public (<name> ratio color) (-> Frac Color Color) (..interpolated ratio <target> color))] @@ -340,7 +340,7 @@ ) (template [<op> <name>] - [(def: #export (<name> ratio color) + [(def: .public (<name> ratio color) (-> Frac Color Color) (let [[hue saturation luminance] (hsl color)] (of_hsl [hue @@ -353,7 +353,7 @@ [f.- un_saturated] ) -(def: #export (gray_scale color) +(def: .public (gray_scale color) (-> Color Color) (let [[_ _ luminance] (hsl color)] (of_hsl [+0.0 @@ -366,7 +366,7 @@ (in (list (` {#.doc (.doc (~ g!documentation))}))))) (template [<name> <1> <2>] - [(`` (def: #export (<name> color) + [(`` (def: .public (<name> color) (~~ (..color_scheme_documentation <name>)) (-> Color [Color Color Color]) (let [[hue saturation luminance] (hsl color)] @@ -384,7 +384,7 @@ ) (template [<name> <1> <2> <3>] - [(`` (def: #export (<name> color) + [(`` (def: .public (<name> color) (~~ (..color_scheme_documentation <name>)) (-> Color [Color Color Color Color]) (let [[hue saturation luminance] (hsb color)] @@ -403,10 +403,10 @@ [tetradic (|> +2.0 (f./ +12.0)) (|> +6.0 (f./ +12.0)) (|> +8.0 (f./ +12.0))] ) -(type: #export Spread +(type: .public Spread Frac) -(type: #export Palette +(type: .public Palette (-> Spread Nat Color (List Color))) (syntax: (palette_documentation {name <code>.local_identifier}) @@ -414,7 +414,7 @@ g!documentation (code.text (format "A " name " palette."))] (in (list (` {#.doc (.doc (~ g!documentation))}))))) -(`` (def: #export (analogous spread variations color) +(`` (def: .public (analogous spread variations color) (~~ (..palette_documentation analogous)) Palette (let [[hue saturation brightness] (hsb color) @@ -425,7 +425,7 @@ brightness])) (list.indices variations))))) -(`` (def: #export (monochromatic spread variations color) +(`` (def: .public (monochromatic spread variations color) (~~ (..palette_documentation monochromatic)) Palette (let [[hue saturation brightness] (hsb color) @@ -438,26 +438,26 @@ [hue saturation] of_hsb)))))) -(type: #export Alpha +(type: .public Alpha {#.doc (doc "The degree of transparency of a pigment.")} Rev) -(def: #export transparent +(def: .public transparent {#.doc (doc "The maximum degree of transparency.")} Alpha rev\bottom) -(def: #export translucent +(def: .public translucent {#.doc (doc "The average degree of transparency.")} Alpha .5) -(def: #export opaque +(def: .public opaque {#.doc (doc "The minimum degree of transparency.")} Alpha rev\top) -(type: #export Pigment +(type: .public Pigment {#.doc (doc "A color with some degree of transparency.")} {#color Color #alpha Alpha}) |