2020-05-08 11:11:20 +08:00
|
|
|
using SDL2;
|
|
|
|
|
|
|
|
namespace Strawberry
|
|
|
|
{
|
|
|
|
static public class Draw
|
|
|
|
{
|
2020-05-23 14:39:46 +08:00
|
|
|
static public Point Camera => Game.Scene != null ? Game.Scene.Camera.Round() : Point.Zero;
|
|
|
|
|
2020-05-08 11:11:20 +08:00
|
|
|
static public void Rect(int x, int y, int w, int h, Color color)
|
|
|
|
{
|
|
|
|
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
2020-05-23 14:39:46 +08:00
|
|
|
SDL.RenderFillRect(Game.Renderer, &SDL.Rect((int32)(x - Camera.X), (int32)(y - Camera.Y), (int32)w, (int32)h));
|
2020-05-08 11:11:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static public void Rect(Rect rect, Color color)
|
|
|
|
{
|
|
|
|
Rect(rect.X, rect.Y, rect.Width, rect.Height, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void HollowRect(int x, int y, int w, int h, Color color)
|
|
|
|
{
|
|
|
|
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
2020-05-23 14:39:46 +08:00
|
|
|
SDL.RenderDrawRect(Game.Renderer, &SDL.Rect((int32)(x - Camera.X), (int32)(y - Camera.Y), (int32)w, (int32)h));
|
2020-05-08 11:11:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static public void HollowRect(Rect rect, Color color)
|
|
|
|
{
|
|
|
|
HollowRect(rect.X, rect.Y, rect.Width, rect.Height, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void Line(Point from, Point to, Color color)
|
|
|
|
{
|
2020-05-23 14:39:46 +08:00
|
|
|
let fromn = (Point)(from - Camera);
|
|
|
|
let ton = (Point)(to - Camera);
|
|
|
|
|
2020-05-08 11:11:20 +08:00
|
|
|
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
2020-05-23 14:39:46 +08:00
|
|
|
SDL.RenderDrawLine(Game.Renderer, (int32)fromn.X, (int32)fromn.Y, (int32)ton.X, (int32)ton.Y);
|
2020-05-08 11:11:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|