Sprite Class
Namespace: Stride.GraphicsAssembly: Stride.Graphics.dll
A sprite.
[DataContract]
[ContentSerializer(typeof(DataContentSerializer<Sprite>))]
[DataSerializerGlobal(typeof(ReferenceSerializer<Sprite>), null, DataSerializerGenericMode.None, false, false, Profile = "Content")]
public class Sprite
Name | Description | |
---|---|---|
Constructors | ||
Sprite() | Create an instance of Sprite with a unique random name. |
|
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. |
|
Sprite(String) | Creates an empty Sprite having the provided name. |
|
Sprite(String, Texture) | Creates a Sprite having the provided texture and name. The region size is initialized with the whole size of the texture. |
|
Fields | ||
DefaultPixelsPerUnit | ||
Properties | ||
Borders | Gets or sets size of the unstretchable borders of source sprite in pixels. |
|
Center | The position of the center of the image in pixels. |
|
HasBorders | Gets the value indicating if the image has unstretchable borders. |
|
IsTransparent | Gets or sets the value indicating if the fragment contains transparent regions. |
|
Name | Gets or sets the name of the image fragment. |
|
Orientation | Gets or sets the rotation to apply to the texture region when rendering the Sprite |
|
PixelsPerUnit | Gets or sets the pixels per scene unit of the sprite. |
|
Region | The rectangle specifying the region of the texture to use as fragment. |
|
Size | Gets the size of the sprite in scene units. Note that the orientation of the image is taken into account in this calculation. |
|
SizeInPixels | Gets the size of the sprite in pixels. Note that the orientation of the image is taken into account in this calculation. |
|
Texture | The texture in which the image is contained |
|
Methods | ||
Clone() | Clone the current sprite. |
|
ToString() |
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
Type | Name | Description |
---|---|---|
Texture | texture | The texture to use as texture |
Sprite(String)
Creates an empty Sprite having the provided name.
public Sprite(string fragmentName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fragmentName | 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
Type | Name | Description |
---|---|---|
System.String | fragmentName | The name of the sprite |
Texture | texture | The texture to use as texture |
Fields
DefaultPixelsPerUnit
public const int DefaultPixelsPerUnit = 100
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
Borders
Gets or sets size of the unstretchable borders of source sprite in pixels.
public Vector4 Borders { get; set; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
Vector2 |
HasBorders
Gets the value indicating if the image has unstretchable borders.
public bool HasBorders { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsTransparent
Gets or sets the value indicating if the fragment contains transparent regions.
public bool IsTransparent { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Name
Gets or sets the name of the image fragment.
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.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
Type | Description |
---|---|
ImageOrientation |
PixelsPerUnit
Gets or sets the pixels per scene unit of the sprite.
public Vector2 PixelsPerUnit { get; set; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
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
Type | Description |
---|---|
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
Type | Description |
---|---|
Vector2 |
Texture
The texture in which the image is contained
public Texture Texture { get; set; }
Property Value
Type | Description |
---|---|
Texture |
Methods
Clone()
Clone the current sprite.
public Sprite Clone()
Returns
Type | Description |
---|---|
Sprite | A new instance of the current sprite. |
ToString()
public override string ToString()
Returns
Type | Description |
---|---|
System.String |