package safe import ( "image" "sync/atomic" ) type Point struct { X, Y atomic.Int64 } func (p *Point) Load() image.Point { return image.Pt( int(p.X.Load()), int(p.Y.Load()), ) } func (p *Point) Store(point image.Point) { p.X.Store(int64(point.X)) p.Y.Store(int64(point.Y)) } type Rectangle struct { Min, Max Point } func (r *Rectangle) Load() image.Rectangle { return image.Rectangle{ Min: r.Min.Load(), Max: r.Max.Load(), } } func (r *Rectangle) Store(rect image.Rectangle) { r.Min.Store(rect.Min) r.Max.Store(rect.Max) }