mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
This commit is contained in:
1 parent
c15547f0d2
commit
f44d0d8a60
30 files changed
+2075
-463
No files matched your search
@@ -121,30 +121,11 @@ func (r *Renderer) canvasEncodedImage(img image.Image) image.Image {
|
||||
// renderImageBorder 渲染图像边框
|
||||
// 入参: ctx 画布上下文, obj 图片对象, box 图像边界, pageH 页面高度, parentCTM 父级CTM, boundaryInCTM 边界是否参与父级CTM, clipPath 裁剪路径
|
||||
func (r *Renderer) renderImageBorder(ctx *canvas.Context, obj ImageObject, box Box, pageH float64, parentCTM *Matrix, boundaryInCTM bool, clipPath *canvas.Path) {
|
||||
border := obj.Border
|
||||
width := defaultPathLineWidth
|
||||
if border.LineWidth != nil {
|
||||
width = *border.LineWidth
|
||||
}
|
||||
if width == 0 {
|
||||
border := imageBorderObject(obj, box)
|
||||
if border.LineWidth == 0 {
|
||||
return
|
||||
}
|
||||
w, h := box.W, box.H
|
||||
data := fmt.Sprintf("M 0 0 L %g 0 L %g %g L 0 %g C", w, w, h, h)
|
||||
rx, ry := min(border.HorizonalCornerRadius, w/2), min(border.VerticalCornerRadius, h/2)
|
||||
if rx > 0 && ry > 0 {
|
||||
data = fmt.Sprintf("M 0 %g A %g %g 0 0 1 %g 0 L %g 0 A %g %g 0 0 1 %g %g L %g %g A %g %g 0 0 1 %g %g L %g %g A %g %g 0 0 1 0 %g C",
|
||||
ry, rx, ry, rx, w-rx, rx, ry, w, ry, w, h-ry, rx, ry, w-rx, h, rx, h, rx, ry, h-ry)
|
||||
}
|
||||
r.renderPath(ctx, PathObject{
|
||||
Boundary: obj.Boundary,
|
||||
LineWidth: width,
|
||||
DashOffset: &border.DashOffset,
|
||||
DashPattern: border.DashPattern,
|
||||
Alpha: obj.Alpha,
|
||||
StrokeColor: border.BorderColor,
|
||||
AbbreviatedData: data,
|
||||
}, pageH, nil, parentCTM, boundaryInCTM, clipPath)
|
||||
r.renderPath(ctx, border, pageH, nil, parentCTM, boundaryInCTM, clipPath)
|
||||
}
|
||||
|
||||
// imageWithClip 应用图片裁剪区域
|
||||
|
||||
Reference in new issue
Block a user