deckgen

package module
v0.0.0-...-6422203 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: CC-BY-SA-3.0 Imports: 2 Imported by: 0

README

deckgen

Documentation

Overview

Package deckgen (generate) performs slide deck generation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Polycoord

func Polycoord(px, py []float64) (string, string)

Polycoord converts slices of coordinates to strings.

Types

type Arc

type Arc struct {
	Dimension
	A1      float64 `xml:"a1,attr"`
	A2      float64 `xml:"a2,attr"`
	Sp      float64 `xml:"sp,attr"`
	Opacity float64 `xml:"opacity,attr"`
}

Arc defines an elliptical arc the arc is defined by a beginning and ending angle in percentages <arc xp="55" yp="10" wp="4" hr="75" a1="0" a2="180"/>

type CommonAttr

type CommonAttr struct {
	Xp          float64 `xml:"xp,attr"`         // X coordinate
	Yp          float64 `xml:"yp,attr"`         // Y coordinate
	Sp          float64 `xml:"sp,attr"`         // size
	Lp          float64 `xml:"lp,attr"`         // linespacing (leading) percentage
	Rotation    float64 `xml:"rotation,attr"`   // Rotation (0-360 degrees)
	Type        string  `xml:"type,attr"`       // type: block, plain, code, number, bullet
	Align       string  `xml:"align,attr"`      // alignment: center, end, begin
	Color       string  `xml:"color,attr"`      // item color
	Gradcolor1  string  `xml:"gradcolor1,attr"` // gradient color 1
	Gradcolor2  string  `xml:"gradcolor2,attr"` // gradient color 2
	GradPercent float64 `xml:"gp,attr"`         // gradient percentage
	Opacity     float64 `xml:"opacity,attr"`    // opacity percentage
	Font        string  `xml:"font,attr"`       // font type: i.e. sans, serif, mono
	Link        string  `xml:"link,attr"`       // reference to other content (i.e. http:// or mailto:)
}

CommonAttr are the common attributes for text and list

type Curve

type Curve struct {
	Xp1     float64 `xml:"xp1,attr"`
	Yp1     float64 `xml:"yp1,attr"`
	Xp2     float64 `xml:"xp2,attr"`
	Yp2     float64 `xml:"yp2,attr"`
	Xp3     float64 `xml:"xp3,attr"`
	Yp3     float64 `xml:"yp3,attr"`
	Sp      float64 `xml:"sp,attr"`
	Color   string  `xml:"color,attr"`
	Opacity float64 `xml:"opacity,attr"`
}

Curve defines a quadratic Bezier curve The begining, ending, and control points are required: <curve xp1="60" yp1="10" xp2="75" yp2="20" xp3="70" yp3="10" />

type Deck

type Deck struct {
	Title       string  `xml:"title"`
	Creator     string  `xml:"creator"`
	Subject     string  `xml:"subject"`
	Publisher   string  `xml:"publisher"`
	Description string  `xml:"description"`
	Date        string  `xml:"date"`
	Canvas      canvas  `xml:"canvas"`
	Slide       []Slide `xml:"slide"`
}

deckmarkup defines the structure of a presentation deck The size of the canvas, and series of slides

type DeckGen

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

DeckGen is the generated deck structure.

func NewSlides

func NewSlides(where io.Writer, w, h int) *DeckGen

NewSlides initializes he generated deck structure.

func (*DeckGen) Arc

func (p *DeckGen) Arc(x, y, w, h, size, a1, a2 float64, color string, opacity ...float64)

Arc makes an arc centered at (x,y), with specified color (with optional opacity), with dimensions (w,h), between angle a1 and a2 (specified in degrees).

func (*DeckGen) Circle

func (p *DeckGen) Circle(x, y, w float64, color string, opacity ...float64)

Circle makes a circle, centered at (x,y) with width w, at the specified color and optional opacity.

func (*DeckGen) Code

func (p *DeckGen) Code(x, y float64, s string, size, margin float64, color string, opacity ...float64)

Code makes a code block at (x,y), with specified size and color (opacity is optional), on a light gray background with the specified margin width.

func (*DeckGen) Curve

func (p *DeckGen) Curve(x1, y1, x2, y2, x3, y3, size float64, color string, opacity ...float64)

Curve makes a Bezier curve between (x1, y2) and (x3, y3), with control points at (x2, y2), thickness is specified by size.

func (*DeckGen) Ellipse

func (p *DeckGen) Ellipse(x, y, w, h float64, color string, opacity ...float64)

Ellipse makes a ellipse graphic, centered at (x,y), with (w,h) dimensions, at the specified color and optional opacity.

func (*DeckGen) EndDeck

func (p *DeckGen) EndDeck()

EndDeck ends a slide.

func (*DeckGen) EndSlide

func (p *DeckGen) EndSlide()

EndSlide ends a slide.

func (*DeckGen) Image

func (p *DeckGen) Image(x, y float64, w, h int, name, link string)

Image places the named image centered at (x, y), with dimensions of (w, h).

func (*DeckGen) Line

func (p *DeckGen) Line(x1, y1, x2, y2, size float64, color string, opacity ...float64)

Line makes a line from (x1,y1) to (x2, y2), with the specified color with optional opacity; thickness is size.

func (*DeckGen) List

func (p *DeckGen) List(x, y, size, spacing, wrap float64, items []string, ltype, font, color string)

List makes a plain, bullet, or plain list with the specified font, size and color, with optional spacing

func (*DeckGen) Polygon

func (p *DeckGen) Polygon(x, y []float64, color string, opacity ...float64)

Polygon makes a polygon with the specified color (with optional opacity), with coordinates in x and y slices.

func (*DeckGen) Polyline

func (p *DeckGen) Polyline(x, y []float64, size float64, color string, opacity ...float64)

Polyline makes a polyline with the specified color and thickness (with optional opacity), with coordinates in x and y slices.

func (*DeckGen) Rect

func (p *DeckGen) Rect(x, y, w, h float64, color string, opacity ...float64)

Rect makes a rectangle, centered at (x,y), with (w,h) dimensions, at the specified color and optional opacity.

func (*DeckGen) Square

func (p *DeckGen) Square(x, y, w float64, color string, opacity ...float64)

Square makes a square, centered at (x,y), with width w, at the specified color and optional opacity.

func (*DeckGen) StartDeck

func (p *DeckGen) StartDeck()

StartDeck begins a slide

func (*DeckGen) StartSlide

func (p *DeckGen) StartSlide(colors ...string)

StartSlide begins a slide.

func (*DeckGen) Text

func (p *DeckGen) Text(x, y float64, s, font string, size float64, color string, opacity ...float64)

Text places plain text aligned at (x,y), with specified font, size and color. Opacity is optional

func (*DeckGen) TextBlock

func (p *DeckGen) TextBlock(x, y float64, s, font string, size, margin float64, color string, opacity ...float64)

TextBlock makes a block of text aligned at (x,y), wrapped at margin; with specified font, size and color. Opacity is optional.

func (*DeckGen) TextEnd

func (p *DeckGen) TextEnd(x, y float64, s, font string, size float64, color string, opacity ...float64)

TextEnd places right-justified text aligned at (x,y), with specified font, size and color. Opacity is optional.

func (p *DeckGen) TextLink(x, y float64, s, link, font string, size float64, color string, opacity ...float64)

TextLink places text aligned at (x,y) with a link

func (*DeckGen) TextMid

func (p *DeckGen) TextMid(x, y float64, s, font string, size float64, color string, opacity ...float64)

TextMid places centered text aligned at (x,y), with specified font, size and color. Opacity is optional.

func (*DeckGen) TextRotate

func (p *DeckGen) TextRotate(x, y float64, s, link, font string, rotation, size float64, color string, opacity ...float64)

TextRotate places rotated text

type Dimension

type Dimension struct {
	CommonAttr
	Wp float64 `xml:"wp,attr"` // width percentage
	Hp float64 `xml:"hp,attr"` // height percentage
	Hr float64 `xml:"hr,attr"` // height relative percentage
	Hw float64 `xml:"hw,attr"` // height by width
}

Dimension describes a graphics object with width and height

type Ellipse

type Ellipse struct {
	Dimension
}

Ellipse describes a rectangle with x,y,w,h <ellipse xp="45" yp="10" wp="4" hr="75" color="rgb(0,127,0)"/>

type Image

type Image struct {
	CommonAttr
	Width     int     `xml:"width,attr"`     // image width
	Height    int     `xml:"height,attr"`    // image height
	Scale     float64 `xml:"scale,attr"`     // image scale percentage
	Autoscale string  `xml:"autoscale,attr"` // scale the image to the canvas
	Name      string  `xml:"name,attr"`      // image file name
	Caption   string  `xml:"caption,attr"`   // image caption
}

Image describes an image <image xp="20" yp="30" width="256" height="256" scale="50" name="picture.png" caption="Pretty picture"/>

type Line

type Line struct {
	Xp1     float64 `xml:"xp1,attr"`     // begin x coordinate
	Yp1     float64 `xml:"yp1,attr"`     // begin y coordinate
	Xp2     float64 `xml:"xp2,attr"`     // end x coordinate
	Yp2     float64 `xml:"yp2,attr"`     // end y coordinate
	Sp      float64 `xml:"sp,attr"`      // line thickness
	Color   string  `xml:"color,attr"`   // line color
	Opacity float64 `xml:"opacity,attr"` // line opacity (1-100)
}

Line defines a straight line <line xp1="20" yp1="10" xp2="30" yp2="10"/>

type List

type List struct {
	CommonAttr
	Wp float64    `xml:"wp,attr"`
	Li []ListItem `xml:"li"`
}

List describes the list element

type ListItem

type ListItem struct {
	Color    string  `xml:"color,attr"`
	Opacity  float64 `xml:"opacity,attr"`
	Font     string  `xml:"font,attr"`
	ListText string  `xml:",chardata"`
}

ListItem describes a list item <list xp="20" yp="70" sp="1.5">

<li>canvas<li>
<li>slide</li>

</list>

type Polygon

type Polygon struct {
	XC      string  `xml:"xc,attr"`
	YC      string  `xml:"yc,attr"`
	Color   string  `xml:"color,attr"`
	Opacity float64 `xml:"opacity,attr"`
}

Polygon defines a polygon, x and y coordinates are specified by strings of space-separated percentages: <polygon xc="10 20 30" yc="30 40 50"/>

type Polyline

type Polyline struct {
	XC      string  `xml:"xc,attr"`
	YC      string  `xml:"yc,attr"`
	Sp      float64 `xml:"sp,attr"` // line thickness
	Color   string  `xml:"color,attr"`
	Opacity float64 `xml:"opacity,attr"`
}

Polyline defines a polyline, x and y coordinates are specified by strings of space-separated percentages: <polyline xc="10 20 30" yc="30 40 50"/>

type Rect

type Rect struct {
	Dimension
}

Rect describes a rectangle with x,y,w,h <rect xp="35" yp="10" wp="4" hp="3"/>

type Slide

type Slide struct {
	Bg          string     `xml:"bg,attr"`
	Fg          string     `xml:"fg,attr"`
	Gradcolor1  string     `xml:"gradcolor1,attr"`
	Gradcolor2  string     `xml:"gradcolor2,attr"`
	GradPercent float64    `xml:"gp,attr"`
	Duration    string     `xml:"duration,attr"`
	Note        string     `xml:"note"`
	List        []List     `xml:"list"`
	Text        []Text     `xml:"text"`
	Image       []Image    `xml:"image"`
	Ellipse     []Ellipse  `xml:"ellipse"`
	Line        []Line     `xml:"line"`
	Rect        []Rect     `xml:"rect"`
	Curve       []Curve    `xml:"curve"`
	Arc         []Arc      `xml:"arc"`
	Polygon     []Polygon  `xml:"polygon"`
	Polyline    []Polyline `xml:"polyline"`
}

Slide is the structure of an individual slide within a deck <slide bg="black" fg="rgb(255,255,255)" duration="2s" note="hello, world"> <slide gradcolor1="black" gradcolor2="white" gp="20" duration="2s" note="wassup">

type Text

type Text struct {
	CommonAttr
	Wp    float64 `xml:"wp,attr"`
	File  string  `xml:"file,attr"`
	Tdata string  `xml:",chardata"`
}

Text describes the text element

Jump to

Keyboard shortcuts

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