29 lines
1.1 KiB
Go
29 lines
1.1 KiB
Go
|
package debug
|
||
|
|
||
|
import "image/draw"
|
||
|
import "image/color"
|
||
|
import "golang.org/x/image/math/fixed"
|
||
|
import "git.tebibyte.media/tomo/typeset"
|
||
|
import "git.tebibyte.media/tomo/typeset/internal"
|
||
|
|
||
|
// DrawBounds draws the LayoutBounds, MinimumSize, and LayoutBoundsSpace of a
|
||
|
// TypeSetter to the given image using these colors:
|
||
|
// - Red: LayoutBounds
|
||
|
// - Green: MinimumSize
|
||
|
// - Blue: LayoutBoundsSpace
|
||
|
func DrawBounds (destination draw.Image, setter *typeset.TypeSetter, offset fixed.Point26_6) {
|
||
|
blue := color.RGBA { B: 255, A: 255 }
|
||
|
red := color.RGBA { R: 255, A: 255 }
|
||
|
green := color.RGBA { G: 255, A: 255 }
|
||
|
|
||
|
layoutBoundsSpace := setter.LayoutBoundsSpace()
|
||
|
layoutBounds := setter.LayoutBounds()
|
||
|
|
||
|
minimum := setter.MinimumSize()
|
||
|
minimumRect := internal.RoundRect(fixed.Rectangle26_6 { Max: minimum }.Add(offset).Add(layoutBounds.Min))
|
||
|
internal.DrawRectangleOutline(destination, minimumRect, green)
|
||
|
|
||
|
internal.DrawRectangleOutline(destination, internal.RoundRect(layoutBoundsSpace.Add(offset)), blue)
|
||
|
internal.DrawRectangleOutline(destination, internal.RoundRect(layoutBounds.Add(offset)), red)
|
||
|
}
|