mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 15:06:46 +08:00
This commit is contained in:
1 parent
621473c17f
commit
8b123698e5
2 files changed
+21
-13
No files matched your search
@@ -163,6 +163,7 @@ type PathObject struct {
|
|||||||
Visible *bool `xml:"Visible,attr"`
|
Visible *bool `xml:"Visible,attr"`
|
||||||
Stroke *bool `xml:"Stroke,attr"`
|
Stroke *bool `xml:"Stroke,attr"`
|
||||||
Fill *bool `xml:"Fill,attr"`
|
Fill *bool `xml:"Fill,attr"`
|
||||||
|
Rule string `xml:"Rule,attr"`
|
||||||
StrokeColor *StrokeColor `xml:"StrokeColor"`
|
StrokeColor *StrokeColor `xml:"StrokeColor"`
|
||||||
FillColor *FillColor `xml:"FillColor"`
|
FillColor *FillColor `xml:"FillColor"`
|
||||||
AbbreviatedData string `xml:"AbbreviatedData"`
|
AbbreviatedData string `xml:"AbbreviatedData"`
|
||||||
|
|||||||
+20
-13
@@ -200,30 +200,35 @@ func (r *Renderer) renderPath(ctx *canvas.Context, obj PathObject, pageH float64
|
|||||||
if style.fillPaint == nil {
|
if style.fillPaint == nil {
|
||||||
style.fillPaint = style.fillColor
|
style.fillPaint = style.fillColor
|
||||||
}
|
}
|
||||||
if shouldFill && style.fillPattern != nil {
|
if shouldFill {
|
||||||
fp := p
|
fp := p
|
||||||
|
fillRule := canvas.NonZero
|
||||||
|
if obj.Rule == "Even-Odd" {
|
||||||
|
fillRule = canvas.EvenOdd
|
||||||
|
if clipPath != nil || style.fillPattern != nil {
|
||||||
|
fp = fp.Settle(fillRule)
|
||||||
|
}
|
||||||
|
}
|
||||||
if clipPath != nil {
|
if clipPath != nil {
|
||||||
fp = p.Copy()
|
fp = fp.Copy()
|
||||||
fp.Close()
|
fp.Close()
|
||||||
fp = applyClipPath(fp, clipPath)
|
fp = applyClipPath(fp, clipPath)
|
||||||
}
|
}
|
||||||
r.renderPattern(ctx, style.fillPattern, style.fillPatternColor, pageH, fp, ctm, bx, by)
|
if style.fillPattern != nil {
|
||||||
} else if shouldFill && style.fillPaint != nil {
|
r.renderPattern(ctx, style.fillPattern, style.fillPatternColor, pageH, fp, ctm, bx, by)
|
||||||
ctx.SetFill(style.fillPaint)
|
} else if style.fillPaint != nil {
|
||||||
ctx.SetStrokeColor(canvas.Transparent)
|
ctx.SetFillRule(fillRule)
|
||||||
fp := p
|
ctx.SetFill(style.fillPaint)
|
||||||
if clipPath != nil {
|
ctx.SetStrokeColor(canvas.Transparent)
|
||||||
fp = p.Copy()
|
ctx.DrawPath(0, 0, fp)
|
||||||
fp.Close()
|
|
||||||
fp = applyClipPath(fp, clipPath)
|
|
||||||
}
|
}
|
||||||
ctx.DrawPath(0, 0, fp)
|
|
||||||
}
|
}
|
||||||
shouldStroke := true
|
shouldStroke := true
|
||||||
if obj.Stroke != nil {
|
if obj.Stroke != nil {
|
||||||
shouldStroke = *obj.Stroke
|
shouldStroke = *obj.Stroke
|
||||||
}
|
}
|
||||||
if shouldStroke {
|
if shouldStroke {
|
||||||
|
ctx.SetFillRule(canvas.NonZero)
|
||||||
if style.strokePaint == nil {
|
if style.strokePaint == nil {
|
||||||
style.strokePaint = style.strokeColor
|
style.strokePaint = style.strokeColor
|
||||||
}
|
}
|
||||||
@@ -409,7 +414,6 @@ func (r *Renderer) buildObjectClipPath(clips *Clips, pageH float64, bx, by float
|
|||||||
}
|
}
|
||||||
p := r.buildClipPath(clips, pageH, bx, by, objectCTM)
|
p := r.buildClipPath(clips, pageH, bx, by, objectCTM)
|
||||||
if p != nil && boundaryInCTM && parentCTM != nil {
|
if p != nil && boundaryInCTM && parentCTM != nil {
|
||||||
// TransFlag只控制对象CTM,父级变换仍作用于裁剪区域及边界
|
|
||||||
p = p.Transform(canvas.Matrix{
|
p = p.Transform(canvas.Matrix{
|
||||||
{parentCTM.a, -parentCTM.c, parentCTM.c*pageH + parentCTM.e},
|
{parentCTM.a, -parentCTM.c, parentCTM.c*pageH + parentCTM.e},
|
||||||
{-parentCTM.b, parentCTM.d, pageH*(1-parentCTM.d) - parentCTM.f},
|
{-parentCTM.b, parentCTM.d, pageH*(1-parentCTM.d) - parentCTM.f},
|
||||||
@@ -438,6 +442,9 @@ func (r *Renderer) buildClipPath(clips *Clips, pageH float64, bx, by float64, ob
|
|||||||
cp := r.buildPath(pathObj, pageH, ctm, true)
|
cp := r.buildPath(pathObj, pageH, ctm, true)
|
||||||
cp.Translate(bx, -by)
|
cp.Translate(bx, -by)
|
||||||
cp.Close()
|
cp.Close()
|
||||||
|
if pathObj.Rule == "Even-Odd" {
|
||||||
|
cp = cp.Settle(canvas.EvenOdd)
|
||||||
|
}
|
||||||
if clipPath == nil {
|
if clipPath == nil {
|
||||||
clipPath = cp
|
clipPath = cp
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user