package textmeasure

import (
	

	
)

type rect struct {
	tl *geo.Point
	br *geo.Point
}

func newRect() *rect {
	return &rect{
		tl: geo.NewPoint(0, 0),
		br: geo.NewPoint(0, 0),
	}
}

func ( rect) () float64 {
	return .br.X - .tl.X
}

func ( rect) () float64 {
	return .br.Y - .tl.Y
}

// norm returns the Rect in normal form, such that Max is component-wise greater or equal than Min.
func ( rect) () *rect {
	return &rect{
		tl: geo.NewPoint(
			math.Min(.tl.X, .br.X),
			math.Min(.tl.Y, .br.Y),
		),
		br: geo.NewPoint(
			math.Max(.tl.X, .br.X),
			math.Max(.tl.Y, .br.Y),
		),
	}
}

func ( *rect) ( *rect) *rect {
	 := newRect()
	.tl.X = math.Min(.tl.X, .tl.X)
	.tl.Y = math.Min(.tl.Y, .tl.Y)
	.br.X = math.Max(.br.X, .br.X)
	.br.Y = math.Max(.br.Y, .br.Y)

	return 
}