More of Gfx - sinusinu/Flora GitHub Wiki
We've seen some Gfx
functions used to draw Texture
, setting color, etc.
Gfx
is a static instance provided by Flora. It provides graphics-related functions.
Let's take a look at the functions of Gfx
!
Gfx.SetColor(Color);
Gfx.SetColor(float, float, float, float);
Gfx.SetColor(byte, byte, byte, byte);
Sets the current drawing color.
All the textures drawn after this function call will be "tinted" with the color set with this function.
float
overload expects value of 0 ~ 1
range, while byte
overload excepts value of 0 ~ 255
range.
Color color = Gfx.GetColor();
Gets the current drawing color.
(int width, int height) = Gfx.GetClientSize();
int width = Gfx.GetClientWidth();
int height = Gfx.GetClientHeight();
Gets the size of the window.
Since SDL2 returns both metrics at the same time, Width
/Height
functions work by querying both metrics and simply discarding unwanted value.
If you want to get both width and height, use GetClientSize()
.
Gfx.SetClientSize(int width, int height);
Gfx.SetClientWidth(int width);
Gfx.SetClientHeight(int height);
Sets the size of the window. Does nothing when on fullscreen.
Same warning as GetClientSize
, use SetClientSize(int, int)
if you want to set both metrics.
Gfx.SetWindowMode(WindowMode);
Sets the window mode. Available modes are:
WindowMode.Windowed
WindowMode.Borderless
WindowMode.Exclusive
Gfx.SetView(View);
Gfx.Begin();
Starts the drawing state.
All drawing calls(Clear
, Draw
...) must be placed in between Begin
and End
.
Gfx.Clear();
Gfx.Clear(byte, byte, byte);
Gfx.Clear(float, float, float);
Gfx.Clear(Color);
Clear the screen.
Receives optional clear color. If not given, screen will be cleared with current drawing color.
Gfx.Draw(Texture, float, float, float, float, double, float, float, FlipMode);
Gfx.Draw(TextureRegion, float, float, float, float, double, float, float, FlipMode);
Gfx.End()
Display drawn screen and finishes drawing state.
If Vsync is enabled, Syncing will happen on this function.