// xInRect is whether a particular x-coordinate is vertically constrained by
// a rectangle.
173528
func xInRect(xtest uint, rect Rect) bool {
	x, _, w, _ := RectPieces(rect)
	return int(xtest) >= x && int(xtest) < (x+w)
}
449378
func (i *ImageObj) GetRect() *Rect {

	rect, err := i.getRect()
	if err != nil {
		log.Fatalf("%+v", err)
	}
	return rect
}
1028923
func Concat(xs interface{}) interface{} {
	chk := ty.Check(
		new(func([][]ty.A) []ty.A),
		xs)
	vxs, tflat := chk.Args[0], chk.Returns[0]

	xsLen := vxs.Len()
	vflat := reflect.MakeSlice(tflat, 0, xsLen*3)
	for i := 0; i < xsLen; i++ {
		vflat = reflect.AppendSlice(vflat, vxs.Index(i))
	}
	return vflat.Interface()
}
804332
func Rect(x0, y0, x1, y1 float32) Rectangle {
	return Rectangle{
		image.Rect(int(x0), int(y0), int(x1), int(y1)),
	}
}
420519
func Rectangular(L int) []float64 {
	r := make([]float64, L)

	for i := range r {
		r[i] = 1
	}

	return r
}
604205
func (d Display) Bounds() Rectangle {
	return Rectangle{
		Position: Position{X: *d.o.Bounds.X, Y: *d.o.Bounds.Y},
		Size:     Size{Height: *d.o.Bounds.Height, Width: *d.o.Bounds.Width},
	}
}
785768
func GetXY(x int, y int) (int, int) {
	if y == -1 {
		y = CurrentHeight() + 1
	}

	if x&PCT != 0 {
		x = int((x & 0xFF) * Width() / 100)
	}

	if y&PCT != 0 {
		y = int((y & 0xFF) * Height() / 100)
	}

	return x, y
}
804152
func rotateLeft(x uint32, n uint32) uint32 {
	return (x << n) | (x >> (32 - n))
}
962949
func Select(list SortSlicer, k int) int {
	var (
		start int
		end   = list.Len()
	)
	if k >= end {
		if k == 0 {
			return 0
		}
		panic("kdtree: index out of range")
	}
	if start == end-1 {
		return k
	}

	for {
		if start == end {
			panic("kdtree: internal inconsistency")
		}
		sub := list.Slice(start, end)
		pivot := Partition(sub, rand.Intn(sub.Len()))
		switch {
		case pivot == k:
			return k
		case k < pivot:
			end = pivot + start
		default:
			k -= pivot
			start += pivot
		}
	}
}
337326
func isUnexpectedEOF(err error) bool {
	if xerr, ok := err.(*xml.SyntaxError); ok {
		return xerr.Msg == "unexpected EOF"
	}
	return err == io.ErrUnexpectedEOF
}
858802
func (self *Block) SetRect(x1, y1, x2, y2 int) {
	self.Rectangle = image.Rect(x1, y1, x2, y2)
	self.Inner = image.Rect(
		self.Min.X+1+self.PaddingLeft,
		self.Min.Y+1+self.PaddingTop,
		self.Max.X-1-self.PaddingRight,
		self.Max.Y-1-self.PaddingBottom,
	)
}
809242
func Select(a Type, x interface{}) Type {
	switch a := a.(type) {
	case *Array:
		n, ok := x.(json.Number)
		if !ok {
			return nil
		}
		pos, err := n.Int64()
		if err != nil {
			return nil
		}
		return a.Select(int(pos))
	case *Object:
		return a.Select(x)
	case *Set:
		tpe := TypeOf(x)
		if Compare(a.of, tpe) == 0 {
			return a.of
		}
		if any, ok := a.of.(Any); ok {
			if any.Contains(tpe) {
				return tpe
			}
		}
		return nil
	case Any:
		if Compare(a, A) == 0 {
			return A
		}
		var tpe Type
		for i := range a {
			// TODO(tsandall): test nil/nil
			tpe = Or(Select(a[i], x), tpe)
		}
		return tpe
	default:
		return nil
	}
}
569121
func (cr *Context) Rectangle(x, y, width, height float64) {
	C.cairo_rectangle(cr.Ptr, C.double(x), C.double(y), C.double(width), C.double(height))
	if err := cr.status(); err != nil {
		panic(err)
	}
}
618309
func ParseRect(s string) (r Rect, err error) {
	_, err = fmt.Sscan(s, &r.Min[0], &r.Min[1], &r.Max[0], &r.Max[1])
	return r, err
}
492338
func RectIntersects(aMinX, aMinY, aMaxX, aMaxY, bMinX, bMinY, bMaxX, bMaxY float64) bool {
	return !(aMaxX < bMinX || aMinX > bMaxX || aMaxY < bMinY || aMinY > bMaxY)
}
73525
func (region *Region) NumRectangles() int {
	ret := int(C.cairo_region_num_rectangles(region.Ptr))
	if err := region.status(); err != nil {
		panic(err)
	}
	return ret
}
1051764
func Float64QuickSelect(data []float64, k int) error {
	return QuickSelect(Float64Slice(data), k)
}