handle person shape aspect ratio

This commit is contained in:
Gavin Nishizawa 2023-01-23 20:20:42 -08:00
parent b1beddc9e2
commit d5f2ed00d5
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -72,6 +72,13 @@ func (s shapePerson) GetDimensionsToFit(width, height, paddingX, paddingY float6
shoulderWidth := totalWidth * personShoulderWidthFactor / (1 - 2*personShoulderWidthFactor)
totalWidth += 2 * shoulderWidth
totalHeight := height + paddingY
// prevent the shape's aspect ratio from becoming too extreme
if totalWidth > 1.5*totalHeight {
totalHeight = totalWidth / 1.5
} else if totalHeight > 1.5*totalWidth {
totalWidth = totalHeight / 1.5
}
return totalWidth, totalHeight
}