|
|
|
@ -33,12 +33,26 @@ func (c *containerView) draw(img canvas, st *state) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *containerView) scaleFrame(frame math.Rect, bounds math.Rect) math.Rect {
|
|
|
|
|
xscale := bounds.Width / c.refWidth
|
|
|
|
|
yscale := bounds.Height / c.refHeight
|
|
|
|
|
var (
|
|
|
|
|
xscale = bounds.Width / c.refWidth
|
|
|
|
|
yscale = bounds.Height / c.refHeight
|
|
|
|
|
xrem = bounds.Width % c.refWidth
|
|
|
|
|
yrem = bounds.Height % c.refHeight
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
xremTaken := math.Min(frame.Origin.X, xrem)
|
|
|
|
|
yremTaken := math.Min(frame.Origin.Y, yrem)
|
|
|
|
|
|
|
|
|
|
xinflate := math.Max(xrem-xremTaken, 0)
|
|
|
|
|
yinflate := math.Max(yrem-yremTaken, 0)
|
|
|
|
|
|
|
|
|
|
return math.Rect{
|
|
|
|
|
Origin: math.Vec{xscale * frame.Origin.X, yscale * frame.Origin.Y},
|
|
|
|
|
Width: xscale * frame.Width,
|
|
|
|
|
Height: yscale * frame.Height,
|
|
|
|
|
Origin: math.Vec{
|
|
|
|
|
xscale*frame.Origin.X + xremTaken,
|
|
|
|
|
yscale*frame.Origin.Y + yremTaken,
|
|
|
|
|
},
|
|
|
|
|
Width: xscale*frame.Width + xinflate,
|
|
|
|
|
Height: yscale*frame.Height + yinflate,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|