Documentation
¶
Index ¶
- Constants
- func A4() []sizingOpt
- func Alignment(horizontal Horizontal, vertical Vertical) nodeOpt
- func BackgroundColor(color string) nodeOpt
- func Border(width float64) border
- func BorderColor(color string) nodeOpt
- func ChildGap(gap float64) nodeOpt
- func Children(nodes ...*Node) nodeOpt
- func Direction(dir direction) nodeOpt
- func Fit(opts ...fitOpt) sizingOpt
- func Fixed(value float64) sizingOpt
- func FontColor(color string) textOpt
- func FontSize(size float64) textOpt
- func FontType(fontType string) textOpt
- func Grow() sizingOpt
- func LoadFonts(src ...string) error
- func Max(value float64) fitOpt
- func Min(value float64) fitOpt
- func Padding(top, right, bottom, left float64) nodeOpt
- func RenderToPDF(writer io.Writer, nodes ...*Node) error
- func RenderToPDFWithOptions(root *Node, writer io.Writer, options PDFOptions) error
- func Sizing(opts ...sizingOpt) nodeOpt
- func USLegal() []sizingOpt
- func USLetter() []sizingOpt
- type Horizontal
- type Node
- type PDFOptions
- type Position
- type Size
- type SizeType
- type Type
- type Vertical
Constants ¶
const ( LeftToRight direction = iota TopToBottom )
Variables ¶
This section is empty.
Functions ¶
func A4 ¶
func A4() []sizingOpt
A4 is a custom sizing and should be used with Sizing please use it as spread for example: Sizing(A4()...)
func Alignment ¶ added in v0.1.0
func Alignment(horizontal Horizontal, vertical Vertical) nodeOpt
Alignment sets the horizontal and vertical alignment of the node. Horizontal can be Left, Center, or Right. Vertical can be Top, Middle, or Bottom.
func BackgroundColor ¶
func BackgroundColor(color string) nodeOpt
BackgroundColor set the background color and the value should be hex color either it it has to be either 6 or 7 (including # at the beginning of the color value)
func BorderColor ¶ added in v0.1.0
func BorderColor(color string) nodeOpt
BorderColor set the border color and the value should be hex color either it it has to be either 6 or 7 (including # at the beginning of the color value)
func ChildGap ¶ added in v0.1.0
func ChildGap(gap float64) nodeOpt
ChildGap sets the gap between child nodes in a parent node.
func Children ¶ added in v0.1.3
func Children(nodes ...*Node) nodeOpt
Children appends new children to the parent node this is useful if you have a dynamic component
func Direction ¶ added in v0.1.0
func Direction(dir direction) nodeOpt
Direction use for rendering the direction of the children. There is two possibilities either TopToBottom ot LeftToRight
func Fit ¶ added in v0.1.0
func Fit(opts ...fitOpt) sizingOpt
Fit mostly used in Parent nodes to let the layout engine know that it can expand to fit the children, This is the default value of all nodes
func Fixed ¶ added in v0.1.0
func Fixed(value float64) sizingOpt
Fixed accept a value and make sure the element has the value
func FontColor ¶ added in v0.1.0
func FontColor(color string) textOpt
FontColor sets the font color for text nodes.
func FontType ¶ added in v0.1.0
func FontType(fontType string) textOpt
FontType sets the font type for text nodes.
func Grow ¶ added in v0.1.0
func Grow() sizingOpt
Grow is a way to set either width or height to gorw and fill the remaining of the space
func Max ¶ added in v0.1.0
func Max(value float64) fitOpt
Max is set the value for Width or Height if they are set to either Fit or Grow
func Min ¶ added in v0.1.0
func Min(value float64) fitOpt
Min is set the value for Width or Height if they are set to either Fit or Grow
func Padding ¶
func Padding(top, right, bottom, left float64) nodeOpt
Padding sets the padding for the node.
func RenderToPDF ¶ added in v0.1.0
RenderToPDF renders the node tree to a PDF and writes it to the provided writer
func RenderToPDFWithOptions ¶ added in v0.1.0
func RenderToPDFWithOptions(root *Node, writer io.Writer, options PDFOptions) error
RenderToPDFWithOptions renders the node tree to PDF with additional options
func Sizing ¶ added in v0.1.0
func Sizing(opts ...sizingOpt) nodeOpt
Sizing accept either 0, 1 or 2. If you pass more than 2 arguments it panics 0: default value to use Fit type for both width and height. They will expand to fit the children size 1: Set the Width of the node and set the height to fit 2: Set both Width and Height of the node
Types ¶
type Horizontal ¶
type Horizontal int
Horizontal represents the horizontal alignment of a node. It can be Left, Center, or Right.
const ( Left Horizontal = iota Center Right )
type Node ¶
type Node struct {
Direction direction
Type Type
Value string // For Text nodes
FontColor string // For Text nodes
FontSize float64 // For Text nodes
FontType string // For Text nodes
FontLineHeight float64 // For Text nodes
Position Position
ChildGap float64 // Space between children
Width, Height Size
Padding [4]float64 // Top, Right, Bottom, Left
Horizontal Horizontal
Vertical Vertical
Parent *Node
Children []*Node
Border float64 // Border width for Box nodes
BorderColor string // Border color for Box nodes
BackgroundColor string // Background color for Box nodes
}
Node represents a layout node. It can be a box, text, or image. It contains properties for alignment, size, padding, and children nodes.
func Box ¶ added in v0.1.0
func Box(opts ...nodeOpt) *Node
Box creates a new box node with the specified options. A box node is a container that can hold other nodes and can have a border, background
type PDFOptions ¶ added in v0.1.0
type PDFOptions struct {
Landscape bool
PageSize string // "A4", "A3", "Letter", etc.
MarginTop float64
MarginRight float64
MarginBottom float64
MarginLeft float64
DefaultFont string
DefaultFontSize float64
}
PDFOptions contains options for PDF rendering
func DefaultPDFOptions ¶ added in v0.1.0
func DefaultPDFOptions() PDFOptions
DefaultPDFOptions returns default PDF rendering options
type Position ¶ added in v0.1.0
type Position struct {
X, Y float64
}
Position represents the position of a node in the layout. It contains X and Y coordinates and it will be calculated by the layout engine.
type Size ¶
type Size struct {
Type SizeType
Value float64
// if the value of min or max set to -1
// it means that the value is not set yet
Min float64
Max float64
}
Size represents the size of a node. It contains the type of size (Fit, Fixed, or Grow), the value, and optional min and max values.