MCPcopy
hub / github.com/tdewolff/canvas / And

Method And

util.go:593–603  ·  view source on GitHub ↗

And returns the rectangle that is the overlap of both.

(q Rect)

Source from the content-addressed store, hash-verified

591
592// And returns the rectangle that is the overlap of both.
593func (r Rect) And(q Rect) Rect {
594 x0 := math.Max(r.X0, q.X0)
595 y0 := math.Max(r.Y0, q.Y0)
596 x1 := math.Min(r.X1, q.X1)
597 y1 := math.Min(r.Y1, q.Y1)
598 if x1 <= x0 || y1 <= y0 {
599 return Rect{}
600 }
601 return Rect{x0, y0, x1, y1}
602
603}
604
605// ToPath converts the rectangle to a path.
606func (r Rect) ToPath() *Path {

Callers 7

DrawPreviewWithAssetsFunction · 0.45
TestPathAndFunction · 0.45
TileMethod · 0.45
drawFunction · 0.45
draw2Function · 0.45
drawFunction · 0.45
mainFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestPathAndFunction · 0.36