fix GetInsidePlacement inconsistencies
This commit is contained in:
parent
1594486dce
commit
6b65665b61
2 changed files with 4 additions and 3 deletions
|
|
@ -87,7 +87,8 @@ func (s baseShape) GetInnerBox() *geo.Box {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s baseShape) GetInsidePlacement(_, _, padding float64) geo.Point {
|
func (s baseShape) GetInsidePlacement(_, _, padding float64) geo.Point {
|
||||||
return *geo.NewPoint(s.Box.TopLeft.X+padding, s.Box.TopLeft.Y+padding)
|
innerTL := s.GetInnerBox().TopLeft
|
||||||
|
return *geo.NewPoint(innerTL.X+padding, innerTL.Y+padding)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the minimum shape dimensions needed to fit content (width x height)
|
// return the minimum shape dimensions needed to fit content (width x height)
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ func (s shapeOval) GetInsidePlacement(width, height, padding float64) geo.Point
|
||||||
// r is the ellipse radius on the line between node.TopLeft and the ellipse center
|
// r is the ellipse radius on the line between node.TopLeft and the ellipse center
|
||||||
// see https://math.stackexchange.com/questions/432902/how-to-get-the-radius-of-an-ellipse-at-a-specific-angle-by-knowing-its-semi-majo
|
// see https://math.stackexchange.com/questions/432902/how-to-get-the-radius-of-an-ellipse-at-a-specific-angle-by-knowing-its-semi-majo
|
||||||
r := rx * ry / math.Sqrt(math.Pow(rx*sin, 2)+math.Pow(ry*cos, 2))
|
r := rx * ry / math.Sqrt(math.Pow(rx*sin, 2)+math.Pow(ry*cos, 2))
|
||||||
// we want to offset r-padding away from the center
|
// we want to offset r-padding/2 away from the center
|
||||||
return *geo.NewPoint(s.Box.TopLeft.X+math.Ceil(rx-cos*(r-padding)), s.Box.TopLeft.Y+math.Ceil(ry-sin*(r-padding)))
|
return *geo.NewPoint(s.Box.TopLeft.X+math.Ceil(rx-cos*(r-padding/2)), s.Box.TopLeft.Y+math.Ceil(ry-sin*(r-padding/2)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s shapeOval) Perimeter() []geo.Intersectable {
|
func (s shapeOval) Perimeter() []geo.Intersectable {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue