git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1221 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
chrisf
2007-07-14 06:27:30 +00:00
parent 36491edc12
commit 6e0bf41569
5 changed files with 59 additions and 46 deletions

View File

@@ -7,18 +7,37 @@ namespace OpenRa.Game
{
class Sprite
{
public readonly Point origin;
public readonly Size size;
public readonly Rectangle bounds;
public readonly Sheet sheet;
public readonly TextureChannel channel;
internal Sprite(Sheet sheet, Point origin, Size size, TextureChannel channel)
internal Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
{
this.origin = origin;
this.size = size;
this.bounds = bounds;
this.sheet = sheet;
this.channel = channel;
}
RectangleF TextureCoords
{
get
{
return new RectangleF(
(float)(bounds.Left + 0.5f) / sheet.Size.Width,
(float)(bounds.Top + 0.5f) / sheet.Size.Height,
(float)(bounds.Width) / sheet.Size.Width,
(float)(bounds.Height) / sheet.Size.Height);
}
}
public PointF MapTextureCoords(PointF p)
{
RectangleF uv = TextureCoords;
return new PointF(
p.X > 0 ? uv.Right : uv.Left,
p.Y > 0 ? uv.Bottom : uv.Top);
}
}
public enum TextureChannel