Safe Haskell | None |
---|---|
Language | Haskell98 |
- createShape :: Ptr a -> Ptr b -> Ptr c -> IO Shape
- 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 ()
- getLocalBounds :: SFBounded a => a -> IO FloatRect
- getGlobalBounds :: SFBounded a => a -> IO FloatRect
- updateShape :: Shape -> IO ()
Documentation
:: Ptr a | Callback that provides the point count of the shape |
-> Ptr b | Callback that provides the points of the shape |
-> Ptr c | Data to pass to the callback functions |
-> IO Shape |
Create a new shape.
destroy :: SFResource a => a -> IO () Source
Destroy the given SFML resource.
setPosition :: SFTransformable a => a -> Vec2f -> IO () Source
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).
:: 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 () Source
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 () Source
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 Source
Get the position of a transformable.
:: SFTransformable a | |
=> a | |
-> IO Float | Current rotation, in degrees |
Get the orientation of a transformable.
getScale :: SFTransformable a => a -> IO Vec2f Source
Get the current scale of a transformable
getOrigin :: SFTransformable a => a -> IO Vec2f Source
Get the local origin of a transformable.
move :: SFTransformable a => a -> Vec2f -> IO () Source
Move a transformable by a given offset
This function adds to the current position of the object,
unlike setPosition
which overwrites it.
:: 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 () Source
Scale a transformable.
This function multiplies the current scale of the object,
unlike setScale
which overwrites it.
getTransform :: SFTransformable a => a -> IO Transform Source
Get the combined transform of a transformable.
getInverseTransform :: SFTransformable a => a -> IO Transform Source
Get the inverse of the combined transform of a transformable.
:: 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.
:: 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) Source
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 Source
Get the sub-rectangle of the texture displayed by a texturable.
setFillColor :: SFShape a => a -> Color -> IO () Source
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 () Source
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 Source
Get the fill color of a shape.
getOutlineColor :: SFShape a => a -> IO Color Source
Get the outline color of a shape.
getOutlineThickness :: SFShape a => a -> IO Float Source
Get the outline thickness of a shape.
getPointCount :: SFShape a => a -> IO Int Source
Get the total number of points of a shape.
:: 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.
:: SFShapeResizable a | |
=> a | |
-> Int | New number of points of the shape |
-> IO () |
Set the number of points of a resizable shape.
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.
updateShape :: Shape -> IO () Source
Recompute the internal geometry of a shape.
This function must be called by specialized shape objects everytime their points change (ie. the result of either the getPointCount or getPoint callbacks is different).