minor change
This commit is contained in:
parent
80735cfc0c
commit
f58676289a
34
text/text.go
34
text/text.go
|
@ -187,6 +187,23 @@ func (txt *Text) WriteRune(r rune) (n int, err error) {
|
||||||
return n, nil
|
return n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (txt *Text) Draw(t pixel.Target) {
|
||||||
|
if txt.dirty {
|
||||||
|
txt.trans.SetLen(txt.tris.Len())
|
||||||
|
txt.trans.Update(&txt.tris)
|
||||||
|
|
||||||
|
for i := range txt.trans {
|
||||||
|
txt.trans[i].Position = txt.mat.Project(txt.trans[i].Position)
|
||||||
|
txt.trans[i].Color = txt.trans[i].Color.Mul(txt.col)
|
||||||
|
}
|
||||||
|
|
||||||
|
txt.transD.Dirty()
|
||||||
|
txt.dirty = false
|
||||||
|
}
|
||||||
|
|
||||||
|
txt.transD.Draw(t)
|
||||||
|
}
|
||||||
|
|
||||||
// controlRune checks if r is a control rune (newline, tab, ...). If it is, a new dot position and
|
// controlRune checks if r is a control rune (newline, tab, ...). If it is, a new dot position and
|
||||||
// true is returned. If r is not a control rune, the original dot and false is returned.
|
// true is returned. If r is not a control rune, the original dot and false is returned.
|
||||||
func (txt *Text) controlRune(r rune, dot pixel.Vec) (newDot pixel.Vec, control bool) {
|
func (txt *Text) controlRune(r rune, dot pixel.Vec) (newDot pixel.Vec, control bool) {
|
||||||
|
@ -252,20 +269,3 @@ func (txt *Text) drawBuf() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (txt *Text) Draw(t pixel.Target) {
|
|
||||||
if txt.dirty {
|
|
||||||
txt.trans.SetLen(txt.tris.Len())
|
|
||||||
txt.trans.Update(&txt.tris)
|
|
||||||
|
|
||||||
for i := range txt.trans {
|
|
||||||
txt.trans[i].Position = txt.mat.Project(txt.trans[i].Position)
|
|
||||||
txt.trans[i].Color = txt.trans[i].Color.Mul(txt.col)
|
|
||||||
}
|
|
||||||
|
|
||||||
txt.transD.Dirty()
|
|
||||||
txt.dirty = false
|
|
||||||
}
|
|
||||||
|
|
||||||
txt.transD.Draw(t)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue