Safe Haskell | None |
---|---|
Language | Haskell98 |
SFML.Graphics.Text
- module SFML.Utils
- data TextStyle
- createText :: IO (Either SFException Text)
- copy :: SFCopyable a => a -> IO a
- destroy :: SFResource a => a -> IO ()
- setTextString :: Text -> String -> IO ()
- setTextStringU :: Text -> String -> IO ()
- setTextFont :: Text -> Font -> IO ()
- setTextCharacterSize :: Text -> Int -> IO ()
- setTextStyle :: Text -> [TextStyle] -> IO ()
- setTextColor :: Text -> Color -> IO ()
- getTextString :: Text -> IO String
- getTextUnicodeString :: Text -> IO String
- getTextFont :: Text -> IO (Maybe Font)
- getTextCharacterSize :: Text -> IO Int
- getTextStyle :: Text -> IO TextStyle
- getTextColor :: Text -> IO Color
- findTextCharacterPos :: Text -> Int -> IO Vec2f
- getLocalBounds :: SFBounded a => a -> IO FloatRect
- getGlobalBounds :: SFBounded a => a -> IO FloatRect
Documentation
module SFML.Utils
Text styles.
Constructors
TextRegular | Regular characters, no style |
TextBold | Characters are bold |
TextItalic | Characters are in italic |
TextUnderlined | Characters are underlined |
TextStrikeThrough | Strike through characters |
createText :: IO (Either SFException Text) Source
Create a new text.
copy :: SFCopyable a => a -> IO a Source
Copy the given SFML resource.
destroy :: SFResource a => a -> IO () Source
Destroy the given SFML resource.
setTextString :: Text -> String -> IO () Source
Set the string of a text (from an ANSI string).
A text's string is empty by default.
setTextStringU :: Text -> String -> IO () Source
Set the string of a text (from a unicode string).
setTextFont :: Text -> Font -> IO () Source
Set the font of a text.
The font argument refers to a texture that must exist as long as the text uses it. Indeed, the text doesn't store its own copy of the font, but rather keeps a pointer to the one that you passed to this function. If the font is destroyed and the text tries to use it, the behaviour is undefined.
Set the character size of a text.
The default size is 30.
setTextStyle :: Text -> [TextStyle] -> IO () Source
Set the style of a text.
You can pass a combination of one or more styles, for example [TextBold, sfTextItalic].
The default style is TextRegular.
setTextColor :: Text -> Color -> IO () Source
Set the global color of a text.
By default, the text's color is opaque white.
getTextString :: Text -> IO String Source
Get the string of a text as an ANSI string.
getTextUnicodeString :: Text -> IO String Source
Get the string of a text as a UTF-32 string.
getTextFont :: Text -> IO (Maybe Font) Source
Get the font used by a text.
If the text has no font attached, Nothing
is returned.
The returned pointer is const, which means that you can't modify the font when you retrieve it with this function.
getTextCharacterSize :: Text -> IO Int Source
Get the size of the characters of a text.
getTextStyle :: Text -> IO TextStyle Source
Get the style of a text
getTextColor :: Text -> IO Color Source
Get the global color of a text.
Return the position of the ith character in a text.
This function computes the visual position of a character from its index in the string. The returned position is in global coordinates (translation, rotation, scale and origin are applied).
If the index is out of range, the position of the end of the string is returned.
getLocalBounds :: SFBounded a => a -> IO FloatRect Source
Get the local bounding rectangle of a boundable.
The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.
getGlobalBounds :: SFBounded a => a -> IO FloatRect Source
Get the global bounding rectangle of a shape.
The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.