op/clip: don't panic when Path is used without an initial MoveTo

A Path initialized with Begin should be ready to use with its pen at (0,
0). Make it so.

Updates gio#311

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
Pierre Curto
2021-11-25 09:03:30 +01:00
committed by Elias Naur
parent 74490b4dfc
commit 227c5a132b
2 changed files with 38 additions and 7 deletions
+5 -3
View File
@@ -124,10 +124,12 @@ func (p *Path) Pos() f32.Point { return p.pen }
// Begin the path, storing the path data and final Op into ops.
func (p *Path) Begin(o *op.Ops) {
*p = Path{
ops: &o.Internal,
macro: op.Record(o),
contour: 1,
}
p.hash.SetSeed(pathSeed)
p.ops = &o.Internal
p.macro = op.Record(o)
// Write the TypeAux opcode
data := ops.Write(p.ops, ops.TypeAuxLen)
data[0] = byte(ops.TypeAux)
}