forked from hajimehoshi/ebiten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ebitenutil: use bitmapfont for the debug print
This removes ebitenutil/internal/assets.
- Loading branch information
1 parent
caa04c4
commit dad72b8
Showing
8 changed files
with
101 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2022 The Ebitengine Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build ignore | ||
// +build ignore | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"image" | ||
"image/color" | ||
"image/png" | ||
"os" | ||
|
||
"github.com/hajimehoshi/bitmapfont/v2" | ||
"golang.org/x/image/font" | ||
"golang.org/x/image/math/fixed" | ||
) | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
fmt.Fprintf(os.Stderr, "%v\n", err) | ||
} | ||
} | ||
|
||
func run() error { | ||
// These values are copied from an example in github.com/hajimehoshi/bitmapfont. | ||
const ( | ||
charWidth = 6 | ||
lineHeight = 16 | ||
|
||
dotX = 4 | ||
dotY = 12 | ||
) | ||
|
||
var lines []string | ||
for j := 0; j < 8; j++ { | ||
var line string | ||
for i := 0; i < 32; i++ { | ||
line += string(rune(i + j*32)) | ||
} | ||
lines = append(lines, line) | ||
} | ||
|
||
d := font.Drawer{ | ||
Dst: image.NewRGBA(image.Rect(0, 0, charWidth*32, lineHeight*8)), | ||
Src: image.NewUniform(color.White), | ||
Face: bitmapfont.Face, | ||
Dot: fixed.P(dotX, dotY), | ||
} | ||
for _, line := range lines { | ||
d.Dot.X = fixed.I(dotX) | ||
d.DrawString(line) | ||
d.Dot.Y += fixed.I(lineHeight) | ||
} | ||
|
||
f, err := os.Create("text.png") | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
|
||
if err := png.Encode(f, d.Dst); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.