mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
parent
dad72b874f
commit
074d370096
@ -49,15 +49,11 @@ func DebugPrint(image *ebiten.Image, str string) {
|
||||
//
|
||||
// The available runes are in U+0000 to U+00FF, which is C0 Controls and Basic Latin and C1 Controls and Latin-1 Supplement.
|
||||
func DebugPrintAt(image *ebiten.Image, str string, x, y int) {
|
||||
drawDebugText(image, str, x+1, y+1, true)
|
||||
drawDebugText(image, str, x, y, false)
|
||||
drawDebugText(image, str, x, y)
|
||||
}
|
||||
|
||||
func drawDebugText(rt *ebiten.Image, str string, ox, oy int, shadow bool) {
|
||||
func drawDebugText(rt *ebiten.Image, str string, ox, oy int) {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
if shadow {
|
||||
op.ColorM.Scale(0, 0, 0, 0.5)
|
||||
}
|
||||
x := 0
|
||||
y := 0
|
||||
w, _ := debugPrintTextImage.Size()
|
||||
|
@ -54,17 +54,26 @@ func run() error {
|
||||
lines = append(lines, line)
|
||||
}
|
||||
|
||||
dst := image.NewRGBA(image.Rect(0, 0, charWidth*32+1, lineHeight*8+1))
|
||||
for i, clr := range []color.Color{color.RGBA{0, 0, 0, 0x80}, color.White} {
|
||||
var offsetX int
|
||||
var offsetY int
|
||||
if i == 0 {
|
||||
offsetX = 1
|
||||
offsetY = 1
|
||||
}
|
||||
d := font.Drawer{
|
||||
Dst: image.NewRGBA(image.Rect(0, 0, charWidth*32, lineHeight*8)),
|
||||
Src: image.NewUniform(color.White),
|
||||
Dst: dst,
|
||||
Src: image.NewUniform(clr),
|
||||
Face: bitmapfont.Face,
|
||||
Dot: fixed.P(dotX, dotY),
|
||||
Dot: fixed.P(dotX+offsetX, dotY+offsetY),
|
||||
}
|
||||
for _, line := range lines {
|
||||
d.Dot.X = fixed.I(dotX)
|
||||
d.Dot.X = fixed.I(dotX + offsetX)
|
||||
d.DrawString(line)
|
||||
d.Dot.Y += fixed.I(lineHeight)
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.Create("text.png")
|
||||
if err != nil {
|
||||
@ -72,7 +81,7 @@ func run() error {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if err := png.Encode(f, d.Dst); err != nil {
|
||||
if err := png.Encode(f, dst); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 4.2 KiB |
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user