Files
inventory-plus-plus/server/ui/svg/preserve_aspect_ratio.go
T
angel fb2f4255f4
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Tests / Go tests (push) Failing after 15s
prototyped svg reports
2026-08-20 00:23:54 -06:00

71 lines
1.1 KiB
Go

package svg
import "fmt"
// TODO: consider reworking this WHOLE API/PACKAGE to make it more of a chaining API.
type (
PreserveAspectRatio struct {
Align *AlignValue
MeetOrSlice MeetOrSliceValue
}
AlignValue struct {
X AlignValueComponent
Y AlignValueComponent
}
AlignValueComponent int
MeetOrSliceValue int
)
const (
AlignMid AlignValueComponent = iota
AlignMin
AlignMax
_ MeetOrSliceValue = iota
Meet
Slice
)
func (r PreserveAspectRatio) PrintKey() string {
return "preserveAspectRatio"
}
func (r PreserveAspectRatio) PrintValue() (string, bool) {
if mos := r.MeetOrSlice.String(); mos != "" {
return fmt.Sprintf(`"%s %s"`, r.Align, mos), true
}
return fmt.Sprintf("%q", r.Align), true
}
func (v *AlignValue) String() string {
if v == nil {
return "none"
}
return fmt.Sprintf("x%sY%s", v.X, v.Y)
}
func (v AlignValueComponent) String() string {
switch v {
case AlignMin:
return "Min"
case AlignMax:
return "Max"
default:
return "Mid"
}
}
func (v MeetOrSliceValue) String() string {
switch v {
case Meet:
return "meet"
case Slice:
return "slice"
default:
return ""
}
}