private static void WriteQuad(TextureArea texture, Rectangle rect, IDataStream<TransformedColouredTexturedVertex> dataStream, float alpha) { rect = rect.Translate(-0.5f, -0.5f); dataStream.WriteRange( new[] { MakeVertex(rect.TopLeft, texture.AtlasTopLeft, alpha), MakeVertex(rect.BottomRight, texture.AtlasBottomRight, alpha), MakeVertex(rect.BottomLeft, texture.AtlasBottomLeft, alpha), MakeVertex(rect.TopLeft, texture.AtlasTopLeft, alpha), MakeVertex(rect.TopRight, texture.AtlasTopRight, alpha), MakeVertex(rect.BottomRight, texture.AtlasBottomRight, alpha) }); }
private static void WriteRectangle(Rectangle extents, Color4 colour, IDataStream<TransformedColouredVertex> dataStream) { dataStream.WriteRange( new[] { new TransformedColouredVertex { Colour = colour, Position = new Vector4(extents.BottomLeft.X, extents.BottomLeft.Y, 1.0f, 1.0f) }, new TransformedColouredVertex { Colour = colour, Position = new Vector4(extents.TopLeft.X, extents.TopLeft.Y, 1.0f, 1.0f) }, new TransformedColouredVertex { Colour = colour, Position = new Vector4(extents.TopRight.X, extents.TopRight.Y, 1.0f, 1.0f) }, new TransformedColouredVertex { Colour = colour, Position = new Vector4(extents.BottomLeft.X, extents.BottomLeft.Y, 1.0f, 1.0f) }, new TransformedColouredVertex { Colour = colour, Position = new Vector4(extents.TopRight.X, extents.TopRight.Y, 1.0f, 1.0f) }, new TransformedColouredVertex { Colour = colour, Position = new Vector4(extents.BottomRight.X, extents.BottomRight.Y, 1.0f, 1.0f) } }); }
private static void WriteCroppedQuad(TextureArea texture, Rectangle rect, IDataStream<TransformedColouredTexturedVertex> dataStream, float horizontalCrop, float verticalCrop) { rect = rect.Translate(-0.5f, -0.5f).Scale(horizontalCrop, verticalCrop); var atlasRect = new Rectangle(texture.AtlasTopLeft, texture.AtlasBottomRight); atlasRect = atlasRect.Scale(horizontalCrop, verticalCrop); dataStream.WriteRange( new[] { MakeVertex(rect.TopLeft, atlasRect.TopLeft), MakeVertex(rect.BottomRight, atlasRect.BottomRight), MakeVertex(rect.BottomLeft, atlasRect.BottomLeft), MakeVertex(rect.TopLeft, atlasRect.TopLeft), MakeVertex(rect.TopRight, atlasRect.TopRight), MakeVertex(rect.BottomRight, atlasRect.BottomRight) }); }