Implemented some shape drawing functions to debug character positioning
This commit is contained in:
parent
cc498fa89c
commit
8ef81ecc7f
@ -222,6 +222,12 @@ func (backend *Backend) drawRune (x, y int, character rune) {
|
|||||||
_, mask, maskPoint, _, _ := backend.font.face.Glyph (
|
_, mask, maskPoint, _, _ := backend.font.face.Glyph (
|
||||||
fixed.Point26_6 { },
|
fixed.Point26_6 { },
|
||||||
character)
|
character)
|
||||||
|
strokeRectangle (
|
||||||
|
&image.Uniform {
|
||||||
|
C: backend.config.Color(stone.ColorForeground),
|
||||||
|
},
|
||||||
|
backend.canvas,
|
||||||
|
backend.boundsOfCell(x, y))
|
||||||
draw.DrawMask (
|
draw.DrawMask (
|
||||||
backend.canvas,
|
backend.canvas,
|
||||||
backend.boundsOfCell(x, y),
|
backend.boundsOfCell(x, y),
|
||||||
@ -352,6 +358,44 @@ func findAndLoadFont (name string, size float64) (face font.Face) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fillRectangle (
|
||||||
|
source image.Image,
|
||||||
|
destination draw.Image,
|
||||||
|
bounds image.Rectangle,
|
||||||
|
) {
|
||||||
|
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
||||||
|
for x := bounds.Min.X; x < bounds.Max.X; x ++ {
|
||||||
|
destination.Set(x, y, source.At(x, y))
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func strokeRectangle (
|
||||||
|
source image.Image,
|
||||||
|
destination draw.Image,
|
||||||
|
bounds image.Rectangle,
|
||||||
|
) {
|
||||||
|
x := 0
|
||||||
|
y := bounds.Min.Y
|
||||||
|
for x = bounds.Min.X; x < bounds.Max.X; x ++ {
|
||||||
|
destination.Set(x, y, source.At(x, y))
|
||||||
|
}
|
||||||
|
|
||||||
|
y = bounds.Max.Y - 1
|
||||||
|
for x = bounds.Min.X; x < bounds.Max.X; x ++ {
|
||||||
|
destination.Set(x, y, source.At(x, y))
|
||||||
|
}
|
||||||
|
|
||||||
|
x = bounds.Min.X
|
||||||
|
for y = bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
||||||
|
destination.Set(x, y, source.At(x, y))
|
||||||
|
}
|
||||||
|
|
||||||
|
x = bounds.Max.X - 1
|
||||||
|
for y = bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
||||||
|
destination.Set(x, y, source.At(x, y))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// init registers this backend when the program starts.
|
// init registers this backend when the program starts.
|
||||||
func init () {
|
func init () {
|
||||||
stone.RegisterBackend(factory)
|
stone.RegisterBackend(factory)
|
||||||
|
Loading…
Reference in New Issue
Block a user