fix shape circle functions
This commit is contained in:
parent
ac273cd206
commit
f119d582e0
1 changed files with 9 additions and 2 deletions
|
|
@ -37,12 +37,19 @@ func (s shapeCircle) AspectRatio1() bool {
|
|||
}
|
||||
|
||||
func (s shapeCircle) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) {
|
||||
diameter := math.Ceil(math.Sqrt(math.Pow(width+paddingX, 2) + math.Pow(height+paddingY, 2)))
|
||||
length := math.Max(width+paddingX, height+paddingY)
|
||||
diameter := math.Ceil(math.Sqrt2 * length)
|
||||
return diameter, diameter
|
||||
}
|
||||
|
||||
func (s shapeCircle) GetInsidePlacement(width, height, paddingX, paddingY float64) geo.Point {
|
||||
return *geo.NewPoint(s.Box.TopLeft.X+math.Ceil(s.Box.Width/2-width/2), s.Box.TopLeft.Y+math.Ceil(s.Box.Height/2-height/2))
|
||||
project45 := 1 / math.Sqrt2
|
||||
r := s.Box.Width / 2
|
||||
// we want to offset r-padding/2 away from the center
|
||||
return geo.Point{
|
||||
X: s.Box.TopLeft.X + math.Ceil(r-project45*(r-paddingX/2)),
|
||||
Y: s.Box.TopLeft.Y + math.Ceil(r-project45*(r-paddingY/2)),
|
||||
}
|
||||
}
|
||||
|
||||
func (s shapeCircle) Perimeter() []geo.Intersectable {
|
||||
|
|
|
|||
Loading…
Reference in a new issue