package world import ( "github.com/google/uuid" ) // MapItem is the common interface implemented by all world primitives. type MapItem interface { ID() uuid.UUID } // Point is a point primitive in fixed-point world coordinates. type Point struct { Id uuid.UUID X, Y int } // Line is a line segment primitive in fixed-point world coordinates. type Line struct { Id uuid.UUID X1, Y1 int X2, Y2 int } // Circle is a circle primitive in fixed-point world coordinates. type Circle struct { Id uuid.UUID X, Y int Radius int } // ID returns the point identifier. func (p Point) ID() uuid.UUID { return p.Id } // ID returns the line identifier. func (l Line) ID() uuid.UUID { return l.Id } // ID returns the circle identifier. func (c Circle) ID() uuid.UUID { return c.Id } // MinX returns the minimum X endpoint coordinate of the line. func (l Line) MinX() int { return min(l.X1, l.X2) } // MaxX returns the maximum X endpoint coordinate of the line. func (l Line) MaxX() int { return max(l.X1, l.X2) } // MinY returns the minimum Y endpoint coordinate of the line. func (l Line) MinY() int { return min(l.Y1, l.Y2) } // MaxY returns the maximum Y endpoint coordinate of the line. func (l Line) MaxY() int { return max(l.Y1, l.Y2) } // MinX returns the minimum X coordinate of the circle bbox. func (c Circle) MinX() int { return c.X - c.Radius } // MaxX returns the maximum X coordinate of the circle bbox. func (c Circle) MaxX() int { return c.X + c.Radius } // MinY returns the minimum Y coordinate of the circle bbox. func (c Circle) MinY() int { return c.Y - c.Radius } // MaxY returns the maximum Y coordinate of the circle bbox. func (c Circle) MaxY() int { return c.Y + c.Radius }