diff --git a/path.go b/path.go index dd445d36..15d14f7f 100644 --- a/path.go +++ b/path.go @@ -2215,8 +2215,8 @@ func (p *Path) ToPDF() string { // ToRasterizer rasterizes the path using the given rasterizer and resolution. func (p *Path) ToRasterizer(ras *vector.Rasterizer, resolution Resolution) { dpmm := resolution.DPMM() + // TODO: smoothen path using Ramer-... inside flatten p = p.Flatten(PixelTolerance / dpmm) // tolerance of 1/10 of a pixel - // TODO: smoothen path using Ramer-... dy := float64(ras.Bounds().Size().Y) for i := 0; i < len(p.d); { @@ -2233,7 +2233,7 @@ func (p *Path) ToRasterizer(ras *vector.Rasterizer, resolution Resolution) { } i += cmdLen(cmd) } - if 0 < len(p.d) && p.d[len(p.d)-1] != CloseCmd { + if !p.Closed() { // implicitly close path ras.ClosePath() } diff --git a/path_stroke.go b/path_stroke.go index ce812d2b..2dc84315 100644 --- a/path_stroke.go +++ b/path_stroke.go @@ -625,7 +625,8 @@ func (p *Path) Offset(w float64, fillRule FillRule, tolerance float64) *Path { filling := p.Filling(fillRule) for i, pi := range p.Split() { r := &Path{} - ccw, closed := pi.CCW(), pi.Closed() + ccw := pi.CCW() + closed := pi.Closed() rhs, lhs := pi.offset(w, ButtCap, RoundJoin, false, tolerance) if !closed || (ccw != filling[i]) != positive { r = rhs @@ -634,11 +635,7 @@ func (p *Path) Offset(w float64, fillRule FillRule, tolerance float64) *Path { } if closed { - if ccw { - r = r.Settle(Positive) - } else { - r = r.Settle(Negative) - } + r = r.Settle(Positive) if !filling[i] { r = r.Reverse() } @@ -662,14 +659,8 @@ func (p *Path) Stroke(w float64, cr Capper, jr Joiner, tolerance float64) *Path rhs, lhs := pi.offset(halfWidth, cr, jr, true, tolerance) if lhs != nil { // closed path // inner path should go opposite direction to cancel the outer path - if pi.CCW() { - q = q.Append(rhs.Settle(Positive)) - q = q.Append(lhs.Settle(Positive).Reverse()) - } else { - // outer first, then inner - q = q.Append(lhs.Settle(Negative)) - q = q.Append(rhs.Settle(Negative).Reverse()) - } + q = q.Append(rhs.Settle(Positive)) + q = q.Append(lhs.Settle(Positive).Reverse()) } else { q = q.Append(rhs.Settle(Positive)) }