{-# LANGUAGE OverloadedStrings, CPP #-}
module Text.LaTeX.Packages.Color
(
pcolor
, monochrome
, dvipsnames
, nodvipsnames
, usenames
, Color (..)
, ColorName (..)
, ColorModel (..)
, ColSpec (..)
, Word8
, pagecolor
, color
, textcolor
, colorbox , fcolorbox
, normalcolor
) where
#if !MIN_VERSION_base(4,11,0)
import Text.LaTeX.Base.Syntax ((<>))
#endif
import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Render
import Text.LaTeX.Base.Types
import Data.Text (toLower)
import Data.Word (Word8)
pcolor :: PackageName
pcolor :: PackageName
pcolor = PackageName
"color"
monochrome :: LaTeXC l => l
monochrome :: forall l. LaTeXC l => l
monochrome = l
"monochrome"
dvipsnames :: LaTeXC l => l
dvipsnames :: forall l. LaTeXC l => l
dvipsnames = l
"dvipsnames"
nodvipsnames :: LaTeXC l => l
nodvipsnames :: forall l. LaTeXC l => l
nodvipsnames = l
"nodvipsnames"
usenames :: LaTeXC l => l
usenames :: forall l. LaTeXC l => l
usenames = l
"usenames"
data ColSpec =
DefColor Color
| ModColor ColorModel
| DvipsColor ColorName
deriving Int -> ColSpec -> ShowS
[ColSpec] -> ShowS
ColSpec -> PackageName
forall a.
(Int -> a -> ShowS)
-> (a -> PackageName) -> ([a] -> ShowS) -> Show a
showList :: [ColSpec] -> ShowS
$cshowList :: [ColSpec] -> ShowS
show :: ColSpec -> PackageName
$cshow :: ColSpec -> PackageName
showsPrec :: Int -> ColSpec -> ShowS
$cshowsPrec :: Int -> ColSpec -> ShowS
Show
data Color =
Red
| Green
| Blue
| Yellow
| Cyan
| Magenta
| Black
| White
deriving Int -> Color -> ShowS
[Color] -> ShowS
Color -> PackageName
forall a.
(Int -> a -> ShowS)
-> (a -> PackageName) -> ([a] -> ShowS) -> Show a
showList :: [Color] -> ShowS
$cshowList :: [Color] -> ShowS
show :: Color -> PackageName
$cshow :: Color -> PackageName
showsPrec :: Int -> Color -> ShowS
$cshowsPrec :: Int -> Color -> ShowS
Show
data ColorModel =
RGB Float Float Float
| RGB255 Word8 Word8 Word8
| GrayM Float
| HTML String
| CMYK Float Float Float Float
deriving Int -> ColorModel -> ShowS
[ColorModel] -> ShowS
ColorModel -> PackageName
forall a.
(Int -> a -> ShowS)
-> (a -> PackageName) -> ([a] -> ShowS) -> Show a
showList :: [ColorModel] -> ShowS
$cshowList :: [ColorModel] -> ShowS
show :: ColorModel -> PackageName
$cshow :: ColorModel -> PackageName
showsPrec :: Int -> ColorModel -> ShowS
$cshowsPrec :: Int -> ColorModel -> ShowS
Show
data ColorName =
Apricot | Aquamarine | Bittersweet
| BlueGreen | BlueViolet | BrickRed
| Brown | BurntOrange | CadetBlue
| CarnationPink | Cerulean | CornflowerBlue
| Dandelion | DarkOrchid | Emerald
| ForestGreen | Fuchsia | Goldenrod
| Gray | GreenYellow | JungleGreen
| Lavender | LimeGreen | Mahogany
| Maroon | Melon | MidnightBlue
| Mulberry | NavyBlue | OliveGreen
| Orange | OrangeRed | Orchid
| Peach | Periwinkle | PineGreen
| Plum | ProcessBlue | Purple
| RawSienna | RedOrange | RedViolet
| Rhodamine | RoyalBlue | RubineRed
| Salmon | SeaGreen | Sepia
| SkyBlue | SpringGreen | Tan
| TealBlue | Thistle | Turquoise
| Violet | VioletRed | WildStrawberry
| YellowGreen | YellowOrange
deriving Int -> ColorName -> ShowS
[ColorName] -> ShowS
ColorName -> PackageName
forall a.
(Int -> a -> ShowS)
-> (a -> PackageName) -> ([a] -> ShowS) -> Show a
showList :: [ColorName] -> ShowS
$cshowList :: [ColorName] -> ShowS
show :: ColorName -> PackageName
$cshow :: ColorName -> PackageName
showsPrec :: Int -> ColorName -> ShowS
$cshowsPrec :: Int -> ColorName -> ShowS
Show
instance Render Color where
render :: Color -> Text
render = Text -> Text
toLower forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. IsString a => PackageName -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> PackageName
show
instance Render ColorModel where
render :: ColorModel -> Text
render (RGB Float
r Float
g Float
b) = forall a. Monoid a => [a] -> a
mconcat [ Text
"[rgb]{" , forall a. Render a => [a] -> Text
renderCommas [Float
r,Float
g,Float
b] , Text
"}" ]
render (RGB255 Word8
r Word8
g Word8
b) = forall a. Monoid a => [a] -> a
mconcat [ Text
"[RGB]{" , forall a. Render a => [a] -> Text
renderCommas [Word8
r,Word8
g,Word8
b] , Text
"}" ]
render (GrayM Float
k) = forall a. Monoid a => [a] -> a
mconcat [ Text
"[gray]{" , forall a. Render a => a -> Text
render Float
k , Text
"}"]
render (HTML PackageName
str) = forall a. Monoid a => [a] -> a
mconcat [ Text
"[HTML]{" , forall a. IsString a => PackageName -> a
fromString PackageName
str , Text
"}" ]
render (CMYK Float
c Float
m Float
y Float
k) = forall a. Monoid a => [a] -> a
mconcat [ Text
"[cmyk]{" , forall a. Render a => [a] -> Text
renderCommas [Float
c,Float
m,Float
y,Float
k] , Text
"}" ]
instance Render ColorName where
render :: ColorName -> Text
render = forall a. IsString a => PackageName -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> PackageName
show
instance Render ColSpec where
render :: ColSpec -> Text
render (DefColor Color
c) = forall a. Monoid a => [a] -> a
mconcat [ Text
"{" , forall a. Render a => a -> Text
render Color
c , Text
"}" ]
render (ModColor ColorModel
cm) = forall a. Render a => a -> Text
render ColorModel
cm
render (DvipsColor ColorName
c) = forall a. Monoid a => [a] -> a
mconcat [ Text
"{" , forall a. Render a => a -> Text
render ColorName
c , Text
"}" ]
pagecolor :: LaTeXC l => ColSpec -> l
pagecolor :: forall l. LaTeXC l => ColSpec -> l
pagecolor = (forall l. LaTeXC l => PackageName -> l
commS PackageName
"pagecolor" forall a. Semigroup a => a -> a -> a
<>) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a l. (Render a, LaTeXC l) => a -> l
rendertex
color :: LaTeXC l => ColSpec -> l
color :: forall l. LaTeXC l => ColSpec -> l
color = (forall l. LaTeXC l => PackageName -> l
commS PackageName
"color" forall a. Semigroup a => a -> a -> a
<>) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a l. (Render a, LaTeXC l) => a -> l
rendertex
textcolor :: LaTeXC l => ColSpec -> l -> l
textcolor :: forall l. LaTeXC l => ColSpec -> l -> l
textcolor ColSpec
cs l
l = forall l. LaTeXC l => PackageName -> l
commS PackageName
"textcolor" forall a. Semigroup a => a -> a -> a
<> forall a l. (Render a, LaTeXC l) => a -> l
rendertex ColSpec
cs
forall a. Semigroup a => a -> a -> a
<> forall l. LaTeXC l => l -> l
braces l
l
colorbox :: LaTeXC l => ColSpec -> l -> l
colorbox :: forall l. LaTeXC l => ColSpec -> l -> l
colorbox ColSpec
cs l
l = forall l. LaTeXC l => PackageName -> l
commS PackageName
"colorbox" forall a. Semigroup a => a -> a -> a
<> forall a l. (Render a, LaTeXC l) => a -> l
rendertex ColSpec
cs
forall a. Semigroup a => a -> a -> a
<> forall l. LaTeXC l => l -> l
braces l
l
fcolorbox :: LaTeXC l => ColSpec -> ColSpec -> l -> l
fcolorbox :: forall l. LaTeXC l => ColSpec -> ColSpec -> l -> l
fcolorbox ColSpec
cs1 ColSpec
cs2 l
l =
forall l. LaTeXC l => PackageName -> l
commS PackageName
"fcolorbox" forall a. Semigroup a => a -> a -> a
<> forall a l. (Render a, LaTeXC l) => a -> l
rendertex ColSpec
cs1
forall a. Semigroup a => a -> a -> a
<> forall a l. (Render a, LaTeXC l) => a -> l
rendertex ColSpec
cs2
forall a. Semigroup a => a -> a -> a
<> forall l. LaTeXC l => l -> l
braces l
l
normalcolor :: LaTeXC l => l
normalcolor :: forall l. LaTeXC l => l
normalcolor = forall l. LaTeXC l => PackageName -> l
comm0 PackageName
"normalcolor"