Checkpoint
This commit is contained in:
160 files changed
+76293
-387
No files matched your search
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
Reference in new issue
Block a user