func (self circle) at(phi float64) image.Point {
	x := self.X + int(RoundFloat64(xStretch*self.radius*math.Cos(phi)))
	y := self.Y + int(RoundFloat64(self.radius*math.Sin(phi)))
	return image.Point{X: x, Y: y}
}
computes the point at a given angle phi
package widgets
import (
	"image"
	"math"
	. "github.com/gizak/termui/v3"
)
const (
	piechartOffsetUp = -.5 * math.Pi  
	resolutionFactor = .0001          
	fullCircle       = 2.0 * math.Pi  
	xStretch         = 2.0            
)
type PieChartLabel func(dataIndex int, currentValue float64) string
type PieChart struct {
	Block
	Data           []float64      
	Colors         []Color        
	LabelFormatter PieChartLabel  
	AngleOffset    float64        
}
func NewPieChart() *PieChart {
	return &PieChart{
		Block:       *NewBlock(),
		Colors:      Theme.PieChart.Slices,
		AngleOffset: piechartOffsetUp,
	}
}
func (self *PieChart) Draw(buf *Buffer) {
	self.Block.Draw(buf)
	center := self.Inner.Min.Add(self.Inner.Size().Div(2))
	radius := MinFloat64(float64(self.Inner.Dx()/2/xStretch), float64(self.Inner.Dy()/2))
	sum := SumFloat64Slice(self.Data)
	sliceSizes := make([]float64, len(self.Data))
	for i, v := range self.Data {
		sliceSizes[i] = v / sum * fullCircle
	}
	borderCircle := &circle{center, radius}
	middleCircle := circle{Point: center, radius: radius / 2.0}
	phi := self.AngleOffset
	for i, size := range sliceSizes {
		for j := 0.0; j < size; j += resolutionFactor {
			borderPoint := borderCircle.at(phi + j)
			line := line{P1: center, P2: borderPoint}
			line.draw(NewCell(SHADED_BLOCKS[1], NewStyle(SelectColor(self.Colors, i))), buf)
		}
		phi += size
	}
	if self.LabelFormatter != nil {
		phi = self.AngleOffset
		for i, size := range sliceSizes {
			labelPoint := middleCircle.at(phi + size/2.0)
			if len(self.Data) == 1 {
				labelPoint = center
			}
			buf.SetString(
				self.LabelFormatter(i, self.Data[i]),
				NewStyle(SelectColor(self.Colors, i)),
				image.Pt(labelPoint.X, labelPoint.Y),
			)
			phi += size
		}
	}
}
type circle struct {
	image.Point
	radius float64
}