sf.Shape Class Reference
Shape defines a drawable convex shape ; it also defines helper functions to draw simple shapes like lines, rectangles, circles, etc.
Default constructor: Shape()
Static methods
Circle(X, Y, Radius, Col, Outline = 0., OutlineCol = sf.Color(0, 0, 0))
Create a shape made of a single circle.
X : X coordinate of the center.
Y : Y coordinate of the center.
Radius : Radius
Col : Color used to fill the rectangle.
Outline : Outline width (0 by default).
OutlineCol : Color used to draw the outline (black by default).
Line(X0, Y0, X1, Y1, Thickness, Col, Outline = 0., OutlineCol = sf.Color(0, 0, 0))
Create a shape made of a single line.
X0 : X coordinate of the first point.
Y0 : Y coordinate of the first point.
X1 : X coordinate of the second point.
Y1 : Y coordinate of the second point.
Thickness : Line thickness.
Col : Color used to draw the line
Outline : Outline width (0 by default)
OutlineCol : Color used to draw the outline (black by default).
Rectangle(X0, Y0, X1, Y1, Col, Outline = 0., OutlineCol = sf.Color(0, 0, 0))
Create a shape made of a single rectangle.
X0 : X coordinate of the first point.
Y0 : Y coordinate of the first point.
X1 : X coordinate of the second point.
Y1 : Y coordinate of the second point.
Col : Color used to fill the rectangle.
Outline : Outline width (0 by default).
OutlineCol : Color used to draw the outline (black by default).
Methods
AddPoint(X, Y, Col=sf.Color.White, OutlineCol=sf.Color.Black)
Add a point to the shape.
X : X coordinate of the point
Y : Y coordinate of the point
Col : Color of the point (white by default)
OutlineCol : Outline color of the point (black by default).
EnableFill(Enable)
Enable or disable filling the shape. Fill is enabled by default.
Enable : True to enable, false to disable.
EnableOutline(Enable)
Enable or disable drawing the shape outline. Outline is enabled by default.
Enable : True to enable, false to disable
GetCenter()
Get the center of the object, in coordinates relative to the object.
Inherited
GetColor()
Get the color of the object.
Inherited
GetNbPoints()
Get the number of points composing the shape.
GetOutlineWidth()
Get the width of the shape outline.
GetPointColor(Index)
Get the color of a point.
Index : Index-th point.
GetPointOutlineColor(Index)
Get the outline color of a point.
Index : Index-th point.
GetPointPosition(Index)
Get the position of a point.
Index : Index-th point.
GetPosition()
Get the position of the object.
Inherited
GetRotation()
Get the orientation of the object.
Inherited
GetScale()
Get the scale of the object.
Inherited
Move(OffsetX, OffsetY)
Move the object.
OffsetX : X offset
OffsetY : Y offset
Inherited
Rotate(Angle)
Rotate the object.
Angle : Angle of rotation, in degrees
Inherited
Scale(FactorX, FactorY)
Scale the object.
FactorX : Scaling factor on X (must be strictly positive)
FactorY : Scaling factor on Y (must be strictly positive)
Inherited
SetBlendMode(Mode)
Set the blending mode for the object. The default blend mode is sf.Blend.Alpha
Mode : New blending mode
Inherited
SetCenter(CenterX, CenterY)
Set the center of the object, in coordinates relative to the object.
CenterX : X coordinate of the center
CenterY : Y coordinate of the center
Inherited
SetColor(Color)
Set the color of the object.
Color : New color
Inherited
SetOutlineWidth(Width)
Change the width of the shape outline.
Width : New width (use 0 to remove the outline).
SetPointColor(Index, Color).
Set the color of a point
Index : Index of the point, in range [0, GetNbPoints() - 1]
Col : New color of the Index-th point.
SetPointOutlineColor(Index, Color).
Set the outline color of a point
Index : Index of the point, in range [0, GetNbPoints() - 1]
Col : New color of the Index-th point.
SetPointPosition(Index, X, Y).
Set the position of a point
Index : Index of the point, in range [0, GetNbPoints() - 1]
X : New X coordinate of the Index-th point
Y : New Y coordinate of the Index-th point.
SetPosition(X, Y)
Set the position of the object.
X : New X coordinate
Y : New Y coordinate
Inherited
SetRotation(Rotation)
Set the orientation of the object.
Rotation : Angle of rotation, in degrees
Inherited
SetScale(ScaleX, ScaleY)
Set the scale of the object.
ScaleX : New horizontal scale (must be strictly positive)
ScaleY : New vertical scale (must be strictly positive)
Inherited
SetScaleX(ScaleX)
Set the X scale factor of the object.
ScaleX : New horizontal scale (must be strictly positive)
Inherited
SetScaleY(ScaleY)
Set the Y scale factor of the object.
ScaleY : New vertical scale (must be strictly positive)
Inherited
SetX(X)
Set the X position of the object.
X : New X coordinate
Inherited
SetY(Y)
Set the Y position of the object.
Y : New Y coordinate
Inherited
TransformToGlobal(X, Y)
Transform a point from local coordinates into global coordinates (ie it applies the object's center, translation, rotation and scale to the point). Returns a tuple.
X : X coordinate of the point to transform
Y : Y coordinate of the point to transform
Inherited
TransformToLocal(X, Y)
Transform a point from global coordinates into local coordinates (ie it applies the inverse of object's center, translation, rotation and scale to the point). Returns a tuple.
X : X coordinate of the point to transform
Y : Y coordinate of the point to transform
Inherited