2022-11-03 13:54:49 +00:00
|
|
|
package shape
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math"
|
|
|
|
|
|
|
|
|
|
"oss.terrastruct.com/d2/lib/geo"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type shapeRealSquare struct {
|
|
|
|
|
*baseShape
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewRealSquare(box *geo.Box) Shape {
|
|
|
|
|
return shapeRealSquare{
|
|
|
|
|
baseShape: &baseShape{
|
|
|
|
|
Type: REAL_SQUARE_TYPE,
|
|
|
|
|
Box: box,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s shapeRealSquare) AspectRatio1() bool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s shapeRealSquare) IsRectangular() bool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-23 18:32:12 +00:00
|
|
|
func (s shapeRealSquare) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) {
|
2023-01-25 01:32:42 +00:00
|
|
|
sideLength := math.Ceil(math.Max(width+paddingX, height+paddingY))
|
2022-11-03 13:54:49 +00:00
|
|
|
return sideLength, sideLength
|
|
|
|
|
}
|