mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-07-19 20:11:55 +08:00
JSON fixes. Grids
This commit is contained in:
@ -27,6 +27,12 @@ namespace Strawberry
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public this(JSON json)
|
||||
: this(json["x"], json["y"])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.Set("Point [ ");
|
||||
@ -61,9 +67,19 @@ namespace Strawberry
|
||||
return Point(a.X * b, a.Y * b);
|
||||
}
|
||||
|
||||
static public Point operator*(Point a, Point b)
|
||||
{
|
||||
return Point(a.X * b.X, a.Y * b.Y);
|
||||
}
|
||||
|
||||
static public Point operator/(Point a, int b)
|
||||
{
|
||||
return Point(a.X / b, a.Y / b);
|
||||
}
|
||||
|
||||
static public Point operator/(Point a, Point b)
|
||||
{
|
||||
return Point(a.X / b.X, a.Y / b.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,12 @@ namespace Strawberry
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public this(JSON json)
|
||||
: this(json["x"], json["y"], json["width"], json["height"])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int Left
|
||||
{
|
||||
[Inline]
|
||||
@ -82,6 +88,8 @@ namespace Strawberry
|
||||
}
|
||||
}
|
||||
|
||||
public Point Origin => .(X, Y);
|
||||
|
||||
public Rect MirrorX(int axis = 0)
|
||||
{
|
||||
var rect = this;
|
||||
@ -138,5 +146,25 @@ namespace Strawberry
|
||||
{
|
||||
return Rect(a.X - b.X, a.Y - b.Y, a.Width, a.Height);
|
||||
}
|
||||
|
||||
static public Rect operator/(Rect a, int b)
|
||||
{
|
||||
return Rect(a.X / b, a.Y / b, a.Width / b, a.Height / b);
|
||||
}
|
||||
|
||||
static public Rect operator/(Rect a, Point b)
|
||||
{
|
||||
return Rect(a.X / b.X, a.Y / b.Y, a.Width / b.X, a.Height / b.Y);
|
||||
}
|
||||
|
||||
static public Rect operator*(Rect a, int b)
|
||||
{
|
||||
return Rect(a.X * b, a.Y * b, a.Width * b, a.Height * b);
|
||||
}
|
||||
|
||||
static public Rect operator*(Rect a, Point b)
|
||||
{
|
||||
return Rect(a.X * b.X, a.Y * b.Y, a.Width * b.X, a.Height * b.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user