I made my own draw method with blackjack and hookers

This commit is contained in:
Sasha Koshka 2022-11-17 21:19:23 -05:00
parent 594d1d07be
commit 3cb0ac64fc
2 changed files with 31 additions and 20 deletions

View File

@ -90,17 +90,13 @@ func (backend *Backend) drawRune (
}
if character < 32 { return }
origin := backend.originOfCell(x, y + 1)
destinationRectangle, mask, maskPoint, _, ok := backend.font.face.Glyph (
fixed.Point26_6 {
X: fixed.I(origin.X),
Y: fixed.I(origin.Y - backend.metrics.descent),
},
destinationRectangle, mask, _, _, ok := backend.font.face.Glyph (
fixed.Point26_6 { },
character)
if !ok {
println("warning")
strokeRectangle (
&image.Uniform {
C: backend.config.Color(stone.ColorForeground),
@ -110,7 +106,7 @@ func (backend *Backend) drawRune (
return
}
if backend.drawCellBounds {
if backend.drawCellBounds {
strokeRectangle (
&image.Uniform {
C: backend.config.Color(stone.ColorForeground),
@ -118,17 +114,32 @@ func (backend *Backend) drawRune (
backend.canvas,
backend.boundsOfCell(x, y))
}
draw.DrawMask (
backend.canvas,
destinationRectangle,
&image.Uniform {
C: backend.config.Color(runeColor),
},
image.Point { },
mask,
maskPoint,
draw.Over)
origin.Y += destinationRectangle.Min.Y - backend.metrics.descent
backend.sprayRuneMask(mask, origin, backend.colors[runeColor])
}
func (backend *Backend) sprayRuneMask (
mask image.Image,
at image.Point,
fill xgraphics.BGRA,
) {
bounds := mask.Bounds().Max
for y := 0; y < bounds.Y; y ++ {
for x := 0; x < bounds.X; x ++ {
_, _, _, alpha := mask.At(x, y).RGBA()
backend.canvas.SetBGRA (
x + at.X,
y + at.Y,
xgraphics.BlendBGRA (
backend.colors[stone.ColorBackground],
xgraphics.BGRA {
R: fill.R,
G: fill.G,
B: fill.B,
A: uint8(alpha >> 8),
}))
}}
}
func fillRectangle (

View File

@ -133,7 +133,7 @@ func factory (
Connect(backend.connection, backend.window.Id)
// uncomment these to draw debug bounds
// backend.drawCellBounds = true
// backend.drawCellBounds = true
// backend.drawBufferBounds = true
output = backend