Table of Contents

Class Sprite

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

A sprite.

[DataContract]
[ContentSerializer(typeof(DataContentSerializer<Sprite>))]
[DataSerializerGlobal(typeof(ReferenceSerializer<Sprite>), null, DataSerializerGenericMode.None, false, false, Profile = "Content")]
public class Sprite
Inheritance
Sprite
Extension Methods

Constructors

Sprite()

Create an instance of Sprite with a unique random name.

public Sprite()

Sprite(Texture)

Create an instance of Sprite from the provided Texture. A unique Id is set as name and the Region is initialized to the size of the whole texture.

public Sprite(Texture texture)

Parameters

texture Texture

The texture to use as texture

Sprite(string)

Creates an empty Sprite having the provided name.

public Sprite(string fragmentName)

Parameters

fragmentName string

Name of the fragment

Sprite(string, Texture)

Creates a Sprite having the provided texture and name. The region size is initialized with the whole size of the texture.

public Sprite(string fragmentName, Texture texture)

Parameters

fragmentName string

The name of the sprite

texture Texture

The texture to use as texture

Fields

DefaultPixelsPerUnit

public const int DefaultPixelsPerUnit = 100

Field Value

int

Properties

Borders

Gets or sets size of the unstretchable borders of source sprite in pixels.

public Vector4 Borders { get; set; }

Property Value

Vector4

Remarks

Borders size are ordered as follows X->Left, Y->Top, Z->Right, W->Bottom.

Center

The position of the center of the image in pixels.

public Vector2 Center { get; set; }

Property Value

Vector2

HasBorders

Gets the value indicating if the image has unstretchable borders.

public bool HasBorders { get; }

Property Value

bool

IsTransparent

Gets or sets the value indicating if the fragment contains transparent regions.

public bool IsTransparent { get; set; }

Property Value

bool

Name

Gets or sets the name of the image fragment.

public string Name { get; set; }

Property Value

string

Orientation

Gets or sets the rotation to apply to the texture region when rendering the Sprite

public virtual ImageOrientation Orientation { get; set; }

Property Value

ImageOrientation

PixelsPerUnit

Gets or sets the pixels per scene unit of the sprite.

public Vector2 PixelsPerUnit { get; set; }

Property Value

Vector2

Remarks

The value is clamped to a strictly positive value.

Region

The rectangle specifying the region of the texture to use as fragment.

public RectangleF Region { get; set; }

Property Value

RectangleF

Size

Gets the size of the sprite in scene units. Note that the orientation of the image is taken into account in this calculation.

public Vector2 Size { get; }

Property Value

Vector2

SizeInPixels

Gets the size of the sprite in pixels. Note that the orientation of the image is taken into account in this calculation.

public Vector2 SizeInPixels { get; }

Property Value

Vector2

Texture

The texture in which the image is contained

public Texture Texture { get; set; }

Property Value

Texture

Methods

Clone()

Clone the current sprite.

public Sprite Clone()

Returns

Sprite

A new instance of the current sprite.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.