Skip to content

GraphicsAPI reference

Class Sprite

Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics2D.dll
Guide: Graphics

A region of a texture with a pivot (origin) in source pixels.

C#
public sealed record Sprite : IEquatable<Sprite>

Inheritance

object ← Sprite

Implements

IEquatable<Sprite>

Remarks

Sprites usually come from a SpriteAtlas, which owns their texture.

Constructors

Sprite(Texture, RectF, Vector2)

A region of a texture with a pivot (origin) in source pixels.

C#
public Sprite(Texture Texture, RectF Source, Vector2 Origin)

Parameters

Texture Texture

The texture that holds the pixels; owned by whoever created it (usually an atlas).

Source RectF

The sprite’s rectangle in the texture, in texture pixels.

Origin Vector2

The anchor in source pixels from the sprite’s top-left: the point placed at the drawing position, and the pivot for rotation and scale.

Remarks

Sprites usually come from a SpriteAtlas, which owns their texture.

Properties

Height

Height of the sprite in pixels.

C#
public int Height { get; }

Property Value

int

Origin

The anchor in source pixels from the sprite’s top-left: the point placed at the drawing position, and the pivot for rotation and scale.

C#
public Vector2 Origin { get; init; }

Property Value

Vector2

Source

The sprite’s rectangle in the texture, in texture pixels.

C#
public RectF Source { get; init; }

Property Value

RectF

Texture

The texture that holds the pixels; owned by whoever created it (usually an atlas).

C#
public Texture Texture { get; init; }

Property Value

Texture

Width

Width of the sprite in pixels.

C#
public int Width { get; }

Property Value

int

Methods

<Clone>$()

C#
public Sprite <Clone>$()

Returns

Sprite

Deconstruct(out Texture, out RectF, out Vector2)

C#
public void Deconstruct(out Texture Texture, out RectF Source, out Vector2 Origin)

Parameters

Texture Texture

Source RectF

Origin Vector2

Equals(object?)

C#
public override bool Equals(object? obj)

Parameters

obj object?

Returns

bool

Equals(Sprite?)

C#
public bool Equals(Sprite? other)

Parameters

other Sprite?

Returns

bool

GetHashCode()

C#
public override int GetHashCode()

Returns

int

ToString()

C#
public override string ToString()

Returns

string

Operators

operator ==(Sprite?, Sprite?)

C#
public static bool operator ==(Sprite? left, Sprite? right)

Parameters

left Sprite?

right Sprite?

Returns

bool

operator !=(Sprite?, Sprite?)

C#
public static bool operator !=(Sprite? left, Sprite? right)

Parameters

left Sprite?

right Sprite?

Returns

bool