Table of Contents

Class Graphics

Namespace
SimulationFramework.Drawing
Assembly
SimulationFramework.dll

Provides graphical functionality to the application.

public static class Graphics
Inheritance
Graphics
Inherited Members

Properties

DefaultFont

The default simulation font.

public static IFont DefaultFont { get; }

Property Value

IFont

Methods

CreateTexture(int, int, Color[]?, TextureOptions)

Creates a new texture with the provided data.

public static ITexture CreateTexture(int width, int height, Color[]? colors, TextureOptions options = TextureOptions.None)

Parameters

width int

The width of the texture.

height int

The height of the texture.

colors Color[]

The initial colors of the texture. Must have exactly width * height elements. If this value is null, the texture will be blank.

options TextureOptions

Options that configure the allowed behaviors of the texture.

Returns

ITexture

The newly created texture.

CreateTexture(int, int, TextureOptions)

Creates a new texture without any inital data.

public static ITexture CreateTexture(int width, int height, TextureOptions options = TextureOptions.None)

Parameters

width int

The width of the texture, in pixels.

height int

The height of the texture, in pixels.

options TextureOptions

Options that configure the allowed behaviors of the texture.

Returns

ITexture

The newly created texture.

CreateTexture(int, int, ReadOnlySpan<Color>, TextureOptions)

Creates a new texture with the provided data.

public static ITexture CreateTexture(int width, int height, ReadOnlySpan<Color> colors, TextureOptions options = TextureOptions.None)

Parameters

width int

The width of the texture.

height int

The height of the texture.

colors ReadOnlySpan<Color>

The initial colors of the texture. Must have exactly width * height elements. If this value is null, the texture will be blank.

options TextureOptions

Options that configure the allowed behaviors of the texture.

Returns

ITexture

The newly created texture.

GetOutputCanvas()

Gets window canvas for the current frame.

public static ICanvas GetOutputCanvas()

Returns

ICanvas

LoadFont(ReadOnlySpan<byte>)

Loads a font from encoded font file.

public static IFont LoadFont(ReadOnlySpan<byte> encodedData)

Parameters

encodedData ReadOnlySpan<byte>

The content of the font file.

Returns

IFont

The loaded font.

LoadFont(string)

Loads a font from a file.

public static IFont LoadFont(string path)

Parameters

path string

The path to the font file.

Returns

IFont

The loaded font.

LoadSystemFont(string)

Loads a pre-existing font from the operating system.

If the font is not present, this method will throw an exception.

public static IFont LoadSystemFont(string name)

Parameters

name string

The name of the font to load.

Returns

IFont

The loaded font.

LoadTexture(byte[], TextureOptions)

Loads a texture from an encoded image.

public static ITexture LoadTexture(byte[] encodedData, TextureOptions options = TextureOptions.None)

Parameters

encodedData byte[]

The encoded image bytes.

options TextureOptions

Options that configure the allowed behaviors of the texture.

Returns

ITexture

The texture loaded from the encoded image.

LoadTexture(ReadOnlySpan<byte>, TextureOptions)

Loads a texture from an encoded image.

public static ITexture LoadTexture(ReadOnlySpan<byte> encodedData, TextureOptions options = TextureOptions.None)

Parameters

encodedData ReadOnlySpan<byte>

The encoded image bytes.

options TextureOptions

Options that configure the allowed behaviors of the texture.

Returns

ITexture

The texture loaded from the encoded image.

LoadTexture(string, TextureOptions)

Loads a texture from a file.

public static ITexture LoadTexture(string path, TextureOptions options = TextureOptions.None)

Parameters

path string

The path to the image file.

options TextureOptions

Options that configure the allowed behaviors of the texture.

Returns

ITexture

The texture loaded from the file.

TryLoadSystemFont(string, out IFont?)

Attempts to load a pre-existing font from the operating system.

public static bool TryLoadSystemFont(string name, out IFont? font)

Parameters

name string

The name of the font to load.

font IFont

The loaded font. Will be non-null if this method returns true.

Returns

bool

true if the font was loaded; otherwise false.