module Helm.Graphics2D.Text
(
Text(..)
, FontWeight(..)
, FontStyle(..)
, defaultText
, toText
, showText
, light
, bold
, italic
, oblique
, color
, typeface
, height
) where
import Helm.Color (Color(..), rgb)
data FontWeight
= LightWeight
| NormalWeight
| BoldWeight
deriving (Show, Eq, Ord, Enum, Read)
data FontStyle
= NormalStyle
| ObliqueStyle
| ItalicStyle
deriving (Show, Eq, Ord, Enum, Read)
data Text = Text
{ textString :: String
, textColor :: Color
, textTypeface :: String
, textHeight :: Double
, textWeight :: FontWeight
, textStyle :: FontStyle
} deriving (Show, Eq)
defaultText :: Text
defaultText = Text {
textString = "",
textColor = rgb 0 0 0,
textTypeface = "sans-serif",
textHeight = 14,
textWeight = NormalWeight,
textStyle = NormalStyle
}
toText :: String -> Text
toText str = defaultText { textString = str }
showText :: Show a => a -> Text
showText a = toText $ show a
bold :: Text -> Text
bold txt = txt { textWeight = BoldWeight }
light :: Text -> Text
light txt = txt { textWeight = LightWeight }
italic :: Text -> Text
italic txt = txt { textStyle = ItalicStyle }
oblique :: Text -> Text
oblique txt = txt { textStyle = ObliqueStyle }
color :: Color -> Text -> Text
color col txt = txt { textColor = col }
typeface :: String -> Text -> Text
typeface face txt = txt { textTypeface = face }
height :: Double -> Text -> Text
height size txt = txt { textHeight = size }