v0.0.494 add tables to wpdf
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled

This commit is contained in:
2024-08-07 13:57:29 +02:00
parent f1b4480e0f
commit b78a468632
11 changed files with 646 additions and 13 deletions

View File

@@ -1,6 +1,9 @@
package wpdf
import "gogs.mikescher.com/BlackForestBytes/goext/langext"
import (
"gogs.mikescher.com/BlackForestBytes/goext/dataext"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
)
type PDFRectOpt struct {
x *float64
@@ -8,6 +11,7 @@ type PDFRectOpt struct {
lineWidth *float64
drawColor *PDFColor
fillColor *PDFColor
alpha *dataext.Tuple[float64, PDFBlendMode]
radiusTL *float64
radiusTR *float64
radiusBR *float64
@@ -81,12 +85,18 @@ func (opt *PDFRectOpt) RadiusBR(radius float64) *PDFRectOpt {
return opt
}
func (opt *PDFRectOpt) Alpha(alpha float64, blendMode PDFBlendMode) *PDFRectOpt {
opt.alpha = &dataext.Tuple[float64, PDFBlendMode]{V1: alpha, V2: blendMode}
return opt
}
func (b *WPDFBuilder) Rect(w float64, h float64, styleStr PDFRectStyle, opts ...*PDFRectOpt) {
x := b.GetX()
y := b.GetY()
var lineWidth *float64
var drawColor *PDFColor
var fillColor *PDFColor
var alphaOverride *dataext.Tuple[float64, PDFBlendMode]
radiusTL := float64(0)
radiusTR := float64(0)
radiusBR := float64(0)
@@ -98,6 +108,7 @@ func (b *WPDFBuilder) Rect(w float64, h float64, styleStr PDFRectStyle, opts ...
lineWidth = langext.CoalesceOpt(opt.lineWidth, lineWidth)
drawColor = langext.CoalesceOpt(opt.drawColor, drawColor)
fillColor = langext.CoalesceOpt(opt.fillColor, fillColor)
alphaOverride = langext.CoalesceOpt(opt.alpha, alphaOverride)
radiusTL = langext.Coalesce(opt.radiusTL, radiusTL)
radiusTR = langext.Coalesce(opt.radiusTR, radiusTR)
radiusBR = langext.Coalesce(opt.radiusBR, radiusBR)
@@ -122,5 +133,11 @@ func (b *WPDFBuilder) Rect(w float64, h float64, styleStr PDFRectStyle, opts ...
defer func() { b.SetFillColor(oldR, oldG, oldB) }()
}
if alphaOverride != nil {
oldA, oldBMS := b.b.GetAlpha()
b.b.SetAlpha(alphaOverride.V1, string(alphaOverride.V2))
defer func() { b.b.SetAlpha(oldA, oldBMS) }()
}
b.b.RoundedRectExt(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL, string(styleStr))
}