Skip to content

Commit

Permalink
Merge pull request #2186 from alixander/fix-circle-fit-2
Browse files Browse the repository at this point in the history
fix circle fit again
  • Loading branch information
alixander authored Oct 31, 2024
2 parents c2be040 + 283ba17 commit a814db6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/shape/shape_circle.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func (s shapeCircle) GetDimensionsToFit(width, height, paddingX, paddingY float6
}

func (s shapeCircle) GetInsidePlacement(width, height, paddingX, paddingY float64) geo.Point {
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)),
r := s.GetBox().Width / 2
halfLength := r * math.Sqrt2 / 2.
p := geo.Point{
X: s.GetBox().TopLeft.X + math.Ceil(r-halfLength+paddingX/2.),
Y: s.GetBox().TopLeft.Y + math.Ceil(r-halfLength+paddingY/2.),
}
return p
}

func (s shapeCircle) Perimeter() []geo.Intersectable {
Expand Down

0 comments on commit a814db6

Please sign in to comment.