slab

package module
v0.0.0-...-1dff114 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2025 License: Zlib Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHexColor = errors.New("invalid hex color")
	ErrUnknownColor    = errors.New("unknown color name")
)

Functions

func DrawPresenter

func DrawPresenter(img draw.Image, bounds image.Rectangle, pres *Presentation, index int)

Types

type Alignment

type Alignment int
const (
	Left Alignment = iota
	Center
	Right
)

type FontCollection

type FontCollection struct {
	Regular    *opentype.Font
	Bold       *opentype.Font
	Italic     *opentype.Font
	BoldItalic *opentype.Font
}

type ImageSlide

type ImageSlide struct {
	// contains filtered or unexported fields
}

func NewImageSlide

func NewImageSlide(pat string) (*ImageSlide, error)

func (*ImageSlide) Draw

func (s *ImageSlide) Draw(img draw.Image, bounds image.Rectangle, attr PresConfig)

type Margins

type Margins struct{ Left, Right, Top, Bottom float64 }

func (Margins) Apply

func (m Margins) Apply(r image.Rectangle) image.Rectangle

Apply applies the margin-boundaries to `r` and returns a copy

type Markup

type Markup struct {
	Attr MarkupAttribute /* attributes of following text */
	Text string          /* actual content */
}

type MarkupAttribute

type MarkupAttribute int
const (
	Bold MarkupAttribute = 1 << iota
	Italic
	Underline
	Strikethrough
	Code
	BigText
	NoWrap
)

type MarkupBuilder

type MarkupBuilder struct {
	// contains filtered or unexported fields
}

ParseMarkup parses a limited subset of Markdown into MarkupText.

Supported:

  • Big: ==text==
  • Code: `code`
  • Bold: **text**
  • Italic: *text* or _text_
  • Underline: __text__
  • Strikethrough: ~~text~~
  • No Wrap: @text@

func (*MarkupBuilder) Dirty

func (b *MarkupBuilder) Dirty() bool

func (*MarkupBuilder) Feed

func (b *MarkupBuilder) Feed(content string)

func (*MarkupBuilder) Reset

func (b *MarkupBuilder) Reset()

func (*MarkupBuilder) Text

func (b *MarkupBuilder) Text() MarkupText

type MarkupText

type MarkupText []Markup

func (MarkupText) Draw

func (m MarkupText) Draw(img draw.Image, bounds image.Rectangle, cfg PresConfig)

func (MarkupText) String

func (m MarkupText) String() string

type PresConfig

type PresConfig struct {
	Foreground     image.Image /* uniform */
	Background     image.Image /* uniform */
	Fonts          FontCollection
	MonoFonts      FontCollection
	Margin         Margins
	Align          Alignment
	VAlign         VerticalAlignment
	TabSize        int
	NewlineSpacing float64
	BigText        float64
	FontSize       float64 /* percent of diagonal px */
}

func (*PresConfig) AddAttribute

func (c *PresConfig) AddAttribute(str string) error

type Presentation

type Presentation struct {
	Conf   PresConfig
	Slides []Slide
}

func ParsePresentation

func ParsePresentation(r io.Reader) (*Presentation, error)

type Slide

type Slide struct {
	Conf    PresConfig
	Notes   string
	Content []SlideContent
}

func FinalSlide

func FinalSlide(cfg PresConfig) Slide

func (*Slide) Draw

func (s *Slide) Draw(img draw.Image, bounds image.Rectangle)

type SlideContent

type SlideContent interface {
	Draw(img draw.Image, bounds image.Rectangle, attr PresConfig)
}

type VerticalAlignment

type VerticalAlignment int
const (
	Top VerticalAlignment = iota
	Middle
	Bottom
)

Directories

Path Synopsis
cmd
slab-present command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL