deck: github.com/ajstarks/deck/generate Index | Files

package generate

import "github.com/ajstarks/deck/generate"

Package generate provides a high-level API for the creation of slide decks using the structures of the deck package (github.com/ajstarks/deck).

Initialization of the package specifies the io.Writer destination for the generated markup, along with the width and height of the slides's canvas. (Speciying (0,0) allows the rendering client to use default dimensions).

Each deck element (text, list, image, rect, ellipse, line, curve, arc, and polygon) are supported. Slides use a percentage-based coordinate system (origin at the lower left corner, x increasing left to right, 0-100%, y increasing upwards, 0-100%).

By default slides use black text on a white background. Elements may have colors and opacities applied to them.

Example:

package main

import (
	"os"
	"github.com/ajstarks/deck/generate"
)

func main() {
	deck := generate.NewSlides(os.Stdout, 0, 0)
	deck.StartDeck() // start the deck

	// Text alignment
	deck.StartSlide("rgb(180,180,180)")                 // New slide with a gray background
	deck.Text(50, 80, "Left", "sans", 10, "black")      // left-aligned black text
	deck.TextMid(50, 50, "Center", "sans", 10, "gray")  // centered gray text
	deck.TextEnd(50, 20, "Right", "sans", 10, "white")  // right-aligned white text
	deck.Line(50, 100, 50, 0, 0.2, "black", 20)         // vertical line
	deck.EndSlide() // end the slide

	// List
	items := []string{"First", "Second", "Third", "Fourth", "Fifth"}
	deck.StartSlide()                                    // start a new slide
	deck.Text(10, 90, "Imporant Items", "sans", 5, "")   // title for the list
	deck.List(10, 70, 4, items, "bullet","sans", "red")  // make a bullet list
	deck.EndSlide()                                      // end the slide

	deck.EndDeck() // end the deck
}

Package generate performs slide deck generation

Index

Package Files

doc.go generate.go

func Polycoord Uses

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

Polycoord converts slices of coordinates to strings.

type Deck Uses

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

Deck is the generated deck structure.

func NewSlides Uses

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

NewSlides initializes he generated deck structure.

func (*Deck) Arc Uses

func (p *Deck) 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 (*Deck) Circle Uses

func (p *Deck) 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 (*Deck) Code Uses

func (p *Deck) 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 (*Deck) Curve Uses

func (p *Deck) 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 (*Deck) Ellipse Uses

func (p *Deck) 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 (*Deck) EndDeck Uses

func (p *Deck) EndDeck()

EndDeck ends a slide.

func (*Deck) EndSlide Uses

func (p *Deck) EndSlide()

EndSlide ends a slide.

func (*Deck) Image Uses

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

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

func (*Deck) Line Uses

func (p *Deck) 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 (*Deck) List Uses

func (p *Deck) 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 (*Deck) Polygon Uses

func (p *Deck) 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 (*Deck) Rect Uses

func (p *Deck) 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 (*Deck) Square Uses

func (p *Deck) 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 (*Deck) StartDeck Uses

func (p *Deck) StartDeck()

StartDeck begins a slide deck.

func (*Deck) StartSlide Uses

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

StartSlide begins a slide.

func (*Deck) Text Uses

func (p *Deck) 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 (*Deck) TextBlock Uses

func (p *Deck) 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 (*Deck) TextEnd Uses

func (p *Deck) 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 *Deck) 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 (*Deck) TextMid Uses

func (p *Deck) 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.

Package generate imports 3 packages (graph) and is imported by 3 packages. Updated 2016-08-17. Refresh now. Tools for package owners.