mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
Compare commits
3 Commits
85c0f4444b
...
229a8d6cfd
Author | SHA1 | Date | |
---|---|---|---|
|
229a8d6cfd | ||
|
c9a3ef28eb | ||
|
2b9e307ec2 |
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
||||
github.com/ebitengine/gomobile v0.0.0-20240329170434-1771503ff0a8
|
||||
github.com/ebitengine/hideconsole v1.0.0
|
||||
github.com/ebitengine/oto/v3 v3.3.0-alpha.1
|
||||
github.com/ebitengine/purego v0.8.0-alpha.0.20240404024320-d0aedd0f4393
|
||||
github.com/ebitengine/purego v0.8.0-alpha.0.20240407111646-0e6302132b78
|
||||
github.com/go-text/typesetting v0.1.1-0.20240402181327-ced1d6822703
|
||||
github.com/hajimehoshi/bitmapfont/v3 v3.0.0
|
||||
github.com/hajimehoshi/go-mp3 v0.3.4
|
||||
|
4
go.sum
4
go.sum
@ -4,8 +4,8 @@ github.com/ebitengine/hideconsole v1.0.0 h1:5J4U0kXF+pv/DhiXt5/lTz0eO5ogJ1iXb8Yj
|
||||
github.com/ebitengine/hideconsole v1.0.0/go.mod h1:hTTBTvVYWKBuxPr7peweneWdkUwEuHuB3C1R/ielR1A=
|
||||
github.com/ebitengine/oto/v3 v3.3.0-alpha.1 h1:J2nBmQwPLKc4+yLObytq1jKNydI96l6EjZfgefiqGbk=
|
||||
github.com/ebitengine/oto/v3 v3.3.0-alpha.1/go.mod h1:T2/VV0UWG97GEEf4kORMU2nCneYT/YmwSTxPutSVaUg=
|
||||
github.com/ebitengine/purego v0.8.0-alpha.0.20240404024320-d0aedd0f4393 h1:8mFaXjlt/DLC5MlrnsR71EpK196kVYvPTC2soh06rGU=
|
||||
github.com/ebitengine/purego v0.8.0-alpha.0.20240404024320-d0aedd0f4393/go.mod h1:y8L+ZRLphbdPW2xs41fur/KaW57yTzrFsqsclHyHrTM=
|
||||
github.com/ebitengine/purego v0.8.0-alpha.0.20240407111646-0e6302132b78 h1:9uNVUYEdJkmroySbiQL0sfhZvCYeZaF3os6WuLY1PEQ=
|
||||
github.com/ebitengine/purego v0.8.0-alpha.0.20240407111646-0e6302132b78/go.mod h1:y8L+ZRLphbdPW2xs41fur/KaW57yTzrFsqsclHyHrTM=
|
||||
github.com/go-text/typesetting v0.1.1-0.20240402181327-ced1d6822703 h1:AqtMl9yw7r319Ah4W2afQm3Ql+PEsQKHds18tGvKhog=
|
||||
github.com/go-text/typesetting v0.1.1-0.20240402181327-ced1d6822703/go.mod h1:2+owI/sxa73XA581LAzVuEBZ3WEEV2pXeDswCH/3i1I=
|
||||
github.com/go-text/typesetting-utils v0.0.0-20240317173224-1986cbe96c66 h1:GUrm65PQPlhFSKjLPGOZNPNxLCybjzjYBzjfoBGaDUY=
|
||||
|
@ -101,20 +101,24 @@ type LayoutOptions struct {
|
||||
// If the vertical alignment is center, the rendering region's middle Y comes to the origin.
|
||||
// If the vertical alignment is bottom, the rendering region's bottom Y comes to the origin.
|
||||
func Draw(dst *ebiten.Image, text string, face Face, options *DrawOptions) {
|
||||
if options == nil {
|
||||
options = &DrawOptions{}
|
||||
var layoutOp LayoutOptions
|
||||
var drawOp ebiten.DrawImageOptions
|
||||
|
||||
if options != nil {
|
||||
layoutOp = options.LayoutOptions
|
||||
drawOp = options.DrawImageOptions
|
||||
}
|
||||
|
||||
geoM := options.GeoM
|
||||
for _, g := range AppendGlyphs(nil, text, face, &options.LayoutOptions) {
|
||||
geoM := drawOp.GeoM
|
||||
|
||||
for _, g := range AppendGlyphs(nil, text, face, &layoutOp) {
|
||||
if g.Image == nil {
|
||||
continue
|
||||
}
|
||||
op := &options.DrawImageOptions
|
||||
op.GeoM.Reset()
|
||||
op.GeoM.Translate(g.X, g.Y)
|
||||
op.GeoM.Concat(geoM)
|
||||
dst.DrawImage(g.Image, op)
|
||||
drawOp.GeoM.Reset()
|
||||
drawOp.GeoM.Translate(g.X, g.Y)
|
||||
drawOp.GeoM.Concat(geoM)
|
||||
dst.DrawImage(g.Image, &drawOp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,3 +356,18 @@ func TestConvertToFloat(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #2954
|
||||
func TestDrawOptionsNotModified(t *testing.T) {
|
||||
img := ebiten.NewImage(30, 30)
|
||||
|
||||
op := &text.DrawOptions{}
|
||||
text.Draw(img, "Hello", text.NewGoXFace(bitmapfont.Face), op)
|
||||
|
||||
if got, want := op.GeoM, (ebiten.GeoM{}); got != want {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
if got, want := op.ColorScale, (ebiten.ColorScale{}); got != want {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user