// Center produces the affine transform, centered around the provided point.
492158
func (a Affine) Center(x, y float64) Affine {
	return I.Translate(-x, -y).Mul(a).Translate(x, y)
}
904505
func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA {
	bgBounds := background.Bounds()
	bgW := bgBounds.Dx()
	bgH := bgBounds.Dy()
	bgMinX := bgBounds.Min.X
	bgMinY := bgBounds.Min.Y

	centerX := bgMinX + bgW/2
	centerY := bgMinY + bgH/2

	x0 := centerX - img.Bounds().Dx()/2
	y0 := centerY - img.Bounds().Dy()/2

	return Overlay(background, img, image.Point{x0, y0}, opacity)
}
436670
func (p *Point) format() string {
	if p.X == nil && p.Y == nil {
		return "(inf,inf)"
	}
	return fmt.Sprintf("(%s,%s)", hex.EncodeToString(p.X.Bytes()), hex.EncodeToString(p.Y.Bytes()))
}
737950
func (vec *T) RotateAroundPoint(point *T, angle float32) *T {
	return vec.Sub(point).Rotate(angle).Add(point)
}
726412
func LinesCentroid(line *geom.LineString, extraLines ...*geom.LineString) (centroid geom.Coord) {
	calculator := NewLineCentroidCalculator(line.Layout())
	calculator.AddLine(line)

	for _, l := range extraLines {
		calculator.AddLine(l)
	}

	return calculator.GetCentroid()
}
124085
func (matrix *Matrix) TransformPoint(x, y *float64) {
	C.cairo_matrix_transform_point((*C.cairo_matrix_t)(unsafe.Pointer(matrix)), (*C.double)(unsafe.Pointer(x)), (*C.double)(unsafe.Pointer(y)))
}
1058091
func (t *Table) center(i int) string {
	if i == -1 && !t.borders.Left {
		return t.pRow
	}

	if i == len(t.cs)-1 && !t.borders.Right {
		return t.pRow
	}

	return t.pCenter
}
1111546
func (b *Box) Center(container *Box) {
	widthleftover := container.inner.W - b.frame.W
	heightleftover := container.inner.H - b.frame.H
	b.frame.X = container.inner.X + widthleftover/2
	b.frame.Y = container.inner.Y + heightleftover/2
}
16349
func (t *TextBar) SetCenter(s string, style tcell.Style) {
	t.initialize()
	if style == tcell.StyleDefault {
		style = t.style
	}
	t.center.SetText(s)
	t.center.SetStyle(style)
}
514702
func (a Affine) Rotate(angle float64) Affine {
	s, c := math.Sincos(angle)
	return a.Mul(Affine{
		+c, +s, +0,
		-s, +c, +0,
		+0, +0, +1,
	})
}
883095
func (t T) Circle(center kml.Coordinate, radius, maxErr float64) []kml.Coordinate {
	numVertices := int(math.Ceil(math.Pi / math.Acos((radius-maxErr)/(radius+maxErr))))
	cs := make([]kml.Coordinate, numVertices+1)
	for i := 0; i < numVertices; i++ {
		cs[i] = t.Offset(center, radius, 360*float64(i)/float64(numVertices))
	}
	cs[numVertices] = cs[0]
	return cs
}
972905
func rotate(points []float64, x, y float64, angle int) {
	if angle < 0 || angle > 3 {
		panic("rotate:参数angle必须0,1,2,3三值之一")
	}

	for i := 0; i < len(points); i += 2 {
		px := points[i] - x
		py := points[i+1] - y
		points[i] = px*cos[angle] - py*sin[angle] + x
		points[i+1] = px*sin[angle] + py*cos[angle] + y
	}
}
1237637
func (l Line) Center() Vec {
	return l.A.Add(l.A.To(l.B).Scaled(0.5))
}
134511
func (p *Path) Transform(projector Projector) *Path {
	for i := range p.PointSet {
		projector(&p.PointSet[i])
	}

	return p
}
652180
func (m *Matrix) TranslatePoint(p Point) *Matrix {
	return m.Translate(p.X, p.Y)
}
1073039
func CropCenter(img image.Image, width, height int) *image.NRGBA {
	return CropAnchor(img, width, height, Center)
}
498279
func C(center Vec, radius float64) Circle {
	return Circle{
		Center: center,
		Radius: radius,
	}
}