package world // PrimitiveID is a compact stable identifier for primitives stored in the World. // It is allocated by the World and may be reused after deletion (free-list). type PrimitiveID uint32 // MapItem is the common interface implemented by all world primitives. type MapItem interface { ID() PrimitiveID } // Point is a point primitive in fixed-point world coordinates. type Point struct { Id PrimitiveID X, Y int // Priority controls per-object draw ordering. Smaller draws earlier. Priority int // StyleID references a resolved style in the world's style table. StyleID StyleID // HitSlopPx expands hit-test radius in screen pixels (per-object override). // 0 means "use primitive default". HitSlopPx int } // Line is a line segment primitive in fixed-point world coordinates. type Line struct { Id PrimitiveID X1, Y1 int X2, Y2 int // Priority controls per-object draw ordering. Smaller draws earlier. Priority int // StyleID references a resolved style in the world's style table. StyleID StyleID // HitSlopPx expands hit-test radius in screen pixels (per-object override). // 0 means "use primitive default". HitSlopPx int } // Circle is a circle primitive in fixed-point world coordinates. type Circle struct { Id PrimitiveID X, Y int Radius int // Priority controls per-object draw ordering. Smaller draws earlier. Priority int // StyleID references a resolved style in the world's style table. StyleID StyleID // HitSlopPx expands hit-test radius in screen pixels (per-object override). // 0 means "use primitive default". HitSlopPx int } // ID returns the point identifier. func (p Point) ID() PrimitiveID { return p.Id } // ID returns the line identifier. func (l Line) ID() PrimitiveID { return l.Id } // ID returns the circle identifier. func (c Circle) ID() PrimitiveID { 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 }