// chunkRectangles takes a slice of rtree.Rectangle values and chunks it into `numParts` subslices.
433170
func chunkRectangles(slice rtree.Rectangles, numParts int64) []rtree.Rectangles {
	parts := make([]rtree.Rectangles, numParts)
	for i := int64(0); i < numParts; i++ {
		parts[i] = slice[i*int64(len(slice))/numParts : (i+1)*int64(len(slice))/numParts]
	}
	return parts
}
1320462
func (surface *Surface) FillRects(rects []Rect, color uint32) error {
	if C.SDL_FillRects(surface.cptr(), rects[0].cptr(), C.int(len(rects)), C.Uint32(color)) != 0 {
		return GetError()
	}
	return nil
}
353792
func (pb *Block) Chunks() (ChunkReader, error) {
	if err := pb.startRead(); err != nil {
		return nil, err
	}
	return blockChunkReader{ChunkReader: pb.chunkr, b: pb}, nil
}
76810
func chunkStrings(s []*string, size int) [][]*string {
	var chunks [][]*string
	for len(s) > 0 {
		end := size
		if len(s) < size {
			end = len(s)
		}

		chunks = append(chunks, s[0:end])
		s = s[end:]
	}
	return chunks
}
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,
	)
}
996393
func FilledCircleRGBA(renderer *sdl.Renderer, x, y, rad int32, r, g, b, a uint8) bool {
	_x := C.Sint16(x)
	_y := C.Sint16(y)
	_rad := C.Sint16(rad)
	_r := C.Uint8(r)
	_g := C.Uint8(g)
	_b := C.Uint8(b)
	_a := C.Uint8(a)
	return C.filledCircleRGBA((*C.SDL_Renderer)(unsafe.Pointer(renderer)), _x, _y, _rad, _r, _g, _b, _a) == 0
}
748367
func (document *Document) GetPartPageRectangles() []image.Rectangle {
	var rectangles []image.Rectangle
	rawRectangles := C.GoString(C.get_part_page_rectangles(document.handle))
	pageRectangles := strings.Split(rawRectangles, ";")
	for _, points := range pageRectangles {
		var intPoints []int
		strPoints := strings.Split(points, ",")
		for _, point := range strPoints {
			point = strings.Trim(point, " ")
			i, _ := strconv.Atoi(point)
			intPoints = append(intPoints, i)
		}
		x0, y0 := intPoints[0], intPoints[1]
		x1, y1 := x0+intPoints[2], y0+intPoints[3]
		rectangles = append(rectangles, image.Rect(x0, y0, x1, y1))
	}
	return rectangles
}
1250818
func (rgc *RasterGraphicContext) ClearRect(x1, y1, x2, y2 int) {
	imageColor := image.NewUniform(rgc.current.FillColor)
	draw.Draw(rgc.img, image.Rect(x1, y1, x2, y2), imageColor, image.ZP, draw.Over)
}
878642
func chunkString(str string, size int) []string {
	if str == "" {
		return []string{}
	}

	if size == 0 {
		return []string{str}
	}

	chunks := make([]string, int64(math.Ceil(float64(len(str))/float64(size))))

	for len(str) < len(chunks)*size {
		str = " " + str
	}

	for i := 0; i < len(chunks); i++ {
		start := i * size
		stop := int64(math.Min(float64(start+size), float64(len(str))))
		chunks[i] = str[start:stop]
	}

	chunks[0] = strings.TrimLeft(chunks[0], " ")

	return chunks
}
1141812
func (r *XRect) Pieces() (int, int, int, int) {
	return r.X(), r.Y(), r.Width(), r.Height()
}
353198
func NewGLTriangles(shader *glhf.Shader, t pixel.Triangles) *GLTriangles {
	var gt *GLTriangles
	mainthread.Call(func() {
		gt = &GLTriangles{
			vs:     glhf.MakeVertexSlice(shader, 0, t.Len()),
			shader: shader,
		}
	})
	gt.SetLen(t.Len())
	gt.Update(t)
	return gt
}
560998
func (h *Head) Chunks() (ChunkReader, error) {
	return h.chunksRange(math.MinInt64, math.MaxInt64), nil
}
832221
func numChunks(b []byte) int {
	lenB := len(b)
	if lenB <= ChunkSize {
		return 1
	}
	return len(b)/chunkedDataLen + 1
}
586420
func goSliceRawSlice(s string) []string {
	s = strings.TrimPrefix(s, "[")
	s = strings.TrimSuffix(s, "]")
	s = strings.TrimSpace(s)
	if s == "" {
		return nil
	}
	a := strings.Split(s, " ")
	return a
}
773157
func (p *Painter) DrawRect(x, y, w, h int) {
	for j := 0; j < h; j++ {
		for i := 0; i < w; i++ {
			m := i + x
			n := j + y

			switch {
			case i == 0 && j == 0:
				p.DrawRune(m, n, '┌')
			case i == w-1 && j == 0:
				p.DrawRune(m, n, '┐')
			case i == 0 && j == h-1:
				p.DrawRune(m, n, '└')
			case i == w-1 && j == h-1:
				p.DrawRune(m, n, '┘')
			case i == 0 || i == w-1:
				p.DrawRune(m, n, '│')
			case j == 0 || j == h-1:
				p.DrawRune(m, n, '─')
			}
		}
	}
}
1367182
func MultiPolygonFromBytes(bytes []byte) (*MultiPolygon, error) {
	var result MultiPolygon
	err := json.Unmarshal(bytes, &result)
	return &result, err
}
1066738
func (imd *IMDraw) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
	return imd.batch.MakeTriangles(t)
}