mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
1 parent
9c5ce1d66f
commit
ac198f3351
56 files changed
+3029
-825
No files matched your search
@@ -15,7 +15,6 @@
|
||||
package ofdgo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
|
||||
"github.com/tdewolff/canvas"
|
||||
@@ -66,10 +65,10 @@ func (r *clipRenderer) add(path *canvas.Path) {
|
||||
}
|
||||
|
||||
// buildObjectClipPath 构建对象裁剪路径并应用父级变换
|
||||
// 入参: clips 裁剪对象, pageH 页面高度, bx 边界X坐标, by 边界Y坐标, objectCTM 对象CTM, parentCTM 父级CTM, boundaryInCTM 边界是否参与父级CTM
|
||||
// 入参: clips 裁剪对象, pageH 页面高度, boundary 外接矩形, objectCTM 对象CTM, parentCTM 父级CTM, boundaryInCTM 边界是否参与父级CTM
|
||||
// 返回: *canvas.Path 路径对象
|
||||
func (r *Renderer) buildObjectClipPath(clips *Clips, pageH float64, bx, by float64, objectCTM Matrix, parentCTM *Matrix, boundaryInCTM bool) *canvas.Path {
|
||||
path, err := r.objectGeometryClip(clips, fmt.Sprintf("%g %g 0 0", bx, by), objectCTM, RenderState{Parent: parentCTM, BoundaryInCTM: boundaryInCTM})
|
||||
func (r *Renderer) buildObjectClipPath(clips *Clips, pageH float64, boundary string, objectCTM Matrix, parentCTM *Matrix, boundaryInCTM bool) *canvas.Path {
|
||||
path, err := r.objectGeometryClip(clips, boundary, objectCTM, RenderState{Parent: parentCTM, BoundaryInCTM: boundaryInCTM})
|
||||
if err != nil {
|
||||
r.renderError = err
|
||||
return nil
|
||||
@@ -116,7 +115,7 @@ func (r *Renderer) buildClipPath(clips *Clips, pageH float64, bx, by float64, ob
|
||||
m := areaCTM.Multiply(TranslationMatrix(box.X, box.Y)).Multiply(ctm)
|
||||
ctx := canvas.NewContext(renderer)
|
||||
ctx.SetView(canvas.Matrix{{m.a, -m.c, bx + m.e}, {-m.b, m.d, pageH - by - m.f}})
|
||||
renderer.clip = r.buildObjectClipPath(textObj.Clips, pageH, box.X, box.Y, ctm, &areaCTM, true)
|
||||
renderer.clip = r.buildObjectClipPath(textObj.Clips, pageH, textObj.Boundary, ctm, &areaCTM, true)
|
||||
if renderer.clip != nil {
|
||||
renderer.clip = renderer.clip.Translate(bx, -by)
|
||||
}
|
||||
@@ -167,6 +166,9 @@ func intersectClipPath(parent, current *canvas.Path) *canvas.Path {
|
||||
if currentOK && currentRect.Contains(parent.FastBounds()) {
|
||||
return parent
|
||||
}
|
||||
if result, ok := intersectConvexCanvasPaths(parent, current); ok {
|
||||
return result
|
||||
}
|
||||
return parent.And(current)
|
||||
}
|
||||
|
||||
@@ -208,6 +210,9 @@ func applyClipPath(path, clip *canvas.Path) *canvas.Path {
|
||||
return pathRect.And(rect).ToPath()
|
||||
}
|
||||
}
|
||||
if result, ok := intersectConvexCanvasPaths(path, clip); ok {
|
||||
return result
|
||||
}
|
||||
return path.And(clip)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user