Safe Haskell | None |
---|---|
Language | Haskell98 |
SFML.Graphics.RectangleShape
- module SFML.Utils
- createRectangleShape :: IO (Either SFException RectangleShape)
- copy :: SFCopyable a => a -> IO a
- destroy :: SFResource a => a -> IO ()
- setPosition :: SFTransformable a => a -> Vec2f -> IO ()
- setRotation :: SFTransformable a => a -> Float -> IO ()
- setScale :: SFTransformable a => a -> Vec2f -> IO ()
- setOrigin :: SFTransformable a => a -> Vec2f -> IO ()
- getPosition :: SFTransformable a => a -> IO Vec2f
- getRotation :: SFTransformable a => a -> IO Float
- getScale :: SFTransformable a => a -> IO Vec2f
- getOrigin :: SFTransformable a => a -> IO Vec2f
- move :: SFTransformable a => a -> Vec2f -> IO ()
- rotate :: SFTransformable a => a -> Float -> IO ()
- scale :: SFTransformable a => a -> Vec2f -> IO ()
- getTransform :: SFTransformable a => a -> IO Transform
- getInverseTransform :: SFTransformable a => a -> IO Transform
- setTexture :: SFTexturable a => a -> Texture -> Bool -> IO ()
- setTextureRect :: SFTexturable a => a -> IntRect -> IO ()
- getTexture :: SFTexturable a => a -> IO (Maybe Texture)
- getTextureRect :: SFTexturable a => a -> IO IntRect
- setFillColor :: SFShape a => a -> Color -> IO ()
- setOutlineColor :: SFShape a => a -> Color -> IO ()
- setOutlineThickness :: SFShape a => a -> Float -> IO ()
- getFillColor :: SFShape a => a -> IO Color
- getOutlineColor :: SFShape a => a -> IO Color
- getOutlineThickness :: SFShape a => a -> IO Float
- getPointCount :: SFShape a => a -> IO Int
- getPoint :: SFShape a => a -> Int -> IO Vec2f
- setPointCount :: SFShapeResizable a => a -> Int -> IO ()
- setSize :: RectangleShape -> Vec2f -> IO ()
- getSize :: RectangleShape -> IO Vec2f
- getLocalBounds :: SFBounded a => a -> IO FloatRect
- getGlobalBounds :: SFBounded a => a -> IO FloatRect
Documentation
module SFML.Utils
createRectangleShape :: IO (Either SFException RectangleShape)
Create a new rectangle shape.
copy :: SFCopyable a => a -> IO a
Copy the given SFML resource.
destroy :: SFResource a => a -> IO ()
Destroy the given SFML resource.
setPosition :: SFTransformable a => a -> Vec2f -> IO ()
Set the position of a transformable.
This function completely overwrites the previous position.
See move
to apply an offset based on the previous position instead.
The default position of a transformable object is (0, 0).
Arguments
:: SFTransformable a | |
=> a | |
-> Float | New rotation, in degrees |
-> IO () |
Set the orientation of a transformable.
This function completely overwrites the previous rotation.
See rotate
to add an angle based on the previous rotation instead.
The default rotation of a transformable SFTransformable object is 0.
setScale :: SFTransformable a => a -> Vec2f -> IO ()
Set the scale factors of a transformable.
This function completely overwrites the previous scale.
See scale
to add a factor based on the previous scale instead.
The default scale of a transformable SFTransformable object is (1, 1).
setOrigin :: SFTransformable a => a -> Vec2f -> IO ()
Set the local origin of a transformable.
The origin of an object defines the center point for all transformations (position, scale, rotation).
The coordinates of this point must be relative to the top-left corner of the object, and ignore all transformations (position, scale, rotation).
The default origin of a transformable SFTransformable object is (0, 0).
getPosition :: SFTransformable a => a -> IO Vec2f
Get the position of a transformable.
Arguments
:: SFTransformable a | |
=> a | |
-> IO Float | Current rotation, in degrees |
Get the orientation of a transformable.
getScale :: SFTransformable a => a -> IO Vec2f
Get the current scale of a transformable
getOrigin :: SFTransformable a => a -> IO Vec2f
Get the local origin of a transformable.
move :: SFTransformable a => a -> Vec2f -> IO ()
Move a transformable by a given offset
This function adds to the current position of the object,
unlike setPosition
which overwrites it.
Arguments
:: SFTransformable a | |
=> a | |
-> Float | Angle of rotation, in degrees |
-> IO () |
Rotate a transformable.
This function adds to the current rotation of the object,
unlike setRotation
which overwrites it.
scale :: SFTransformable a => a -> Vec2f -> IO ()
Scale a transformable.
This function multiplies the current scale of the object,
unlike setScale
which overwrites it.
getTransform :: SFTransformable a => a -> IO Transform
Get the combined transform of a transformable.
getInverseTransform :: SFTransformable a => a -> IO Transform
Get the inverse of the combined transform of a transformable.
Arguments
:: SFTexturable a | |
=> a | |
-> Texture | New texture |
-> Bool | Should the texture rect be reset to the size of the new texture? |
-> IO () |
Change the source texture of a Texturable.
The texture argument refers to a texture that must exist as long as the texturable uses it. Indeed, the texturable doesn't store its own copy of the texture, but rather keeps a pointer to the one that you passed to this function.
If the source texture is destroyed and the texturable tries to use it, the behaviour is undefined.
If resetRect is True
, the TextureRect property of
the texturable is automatically adjusted to the size of the new
texture. If it is false, the texture rect is left unchanged.
Arguments
:: SFTexturable a | |
=> a | |
-> IntRect | Rectangle defining the region of the texture to display |
-> IO () |
Set the sub-rectangle of the texture that a texturable will display.
The texture rect is useful when you don't want to display the whole texture, but rather a part of it.
By default, the texture rect covers the entire texture.
getTexture :: SFTexturable a => a -> IO (Maybe Texture)
Get the source texture of a texturable.
If the texturable has no source texture, Nothing
is returned.
The returned pointer is const, which means that you can't modify the texture when you retrieve it with this function.
getTextureRect :: SFTexturable a => a -> IO IntRect
Get the sub-rectangle of the texture displayed by a texturable.
setFillColor :: SFShape a => a -> Color -> IO ()
Set the fill color of a shape.
This color is modulated (multiplied) with the shape's texture if any. It can be used to colorize the shape, or change its global opacity.
You can use Transparent
to make the inside of
the shape transparent, and have the outline alone.
By default, the shape's fill color is opaque white.
setOutlineColor :: SFShape a => a -> Color -> IO ()
Set the outline color of a shape.
You can use Transparent
to disable the outline.
By default, the shape's outline color is opaque white.
Set the thickness of a shape's outline.
This number cannot be negative. Using zero disables the outline.
By default, the outline thickness is 0.
getFillColor :: SFShape a => a -> IO Color
Get the fill color of a shape.
getOutlineColor :: SFShape a => a -> IO Color
Get the outline color of a shape.
getOutlineThickness :: SFShape a => a -> IO Float
Get the outline thickness of a shape.
getPointCount :: SFShape a => a -> IO Int
Get the total number of points of a shape.
Arguments
:: SFShape a | |
=> a | |
-> Int | Index of the point to get, in range [0 .. |
-> IO Vec2f |
Get the ith point of a shape.
The result is undefined if index is out of the valid range.
Arguments
:: SFShapeResizable a | |
=> a | |
-> Int | New number of points of the shape |
-> IO () |
Set the number of points of a resizable shape.
setSize :: RectangleShape -> Vec2f -> IO ()
Set the size of a rectangle shape.
getSize :: RectangleShape -> IO Vec2f
Get the size of a rectangle shape.
getLocalBounds :: SFBounded a => a -> IO FloatRect
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
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.