op/clip: split clip operations into its own package

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-09 19:05:03 +01:00
parent 560cf6054c
commit e864ac3fc3
14 changed files with 72 additions and 53 deletions
+4 -4
View File
@@ -11,7 +11,7 @@ import (
"gioui.org/f32"
"gioui.org/op"
"gioui.org/op/paint"
"gioui.org/op/clip"
"gioui.org/text"
"golang.org/x/image/font"
"golang.org/x/image/font/sfnt"
@@ -43,7 +43,7 @@ func (f *Font) Layout(ppem fixed.Int26_6, str string, opts text.LayoutOptions) *
return layoutText(&f.buf, ppem, str, &opentype{Font: f.font, Hinting: font.HintingFull}, opts)
}
func (f *Font) Shape(ppem fixed.Int26_6, str text.String) paint.ClipOp {
func (f *Font) Shape(ppem fixed.Int26_6, str text.String) clip.Op {
return textPath(&f.buf, ppem, &opentype{Font: f.font, Hinting: font.HintingFull}, str)
}
@@ -136,9 +136,9 @@ func layoutText(buf *sfnt.Buffer, ppem fixed.Int26_6, str string, f *opentype, o
return &text.Layout{Lines: lines}
}
func textPath(buf *sfnt.Buffer, ppem fixed.Int26_6, f *opentype, str text.String) paint.ClipOp {
func textPath(buf *sfnt.Buffer, ppem fixed.Int26_6, f *opentype, str text.String) clip.Op {
var lastPos f32.Point
var builder paint.Path
var builder clip.Path
ops := new(op.Ops)
var x fixed.Int26_6
var advIdx int