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
Polycoord converts slices of coordinates to strings.
type Deck struct {
// contains filtered or unexported fields
}Deck is the generated deck structure.
NewSlides initializes he generated deck structure.
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).
Circle makes a circle, centered at (x,y) with width w, at the specified color and optional opacity.
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.
Curve makes a Bezier curve between (x1, y2) and (x3, y3), with control points at (x2, y2), thickness is specified by size.
Ellipse makes a ellipse graphic, centered at (x,y), with (w,h) dimensions, at the specified color and optional opacity.
EndDeck ends a slide.
EndSlide ends a slide.
Image places the named image centered at (x, y), with dimensions of (w, h).
Line makes a line from (x1,y1) to (x2, y2), with the specified color with optional opacity; thickness is size.
List makes a plain, bullet, or plain list with the specified font, size and color, with optional spacing
Polygon makes a polygon with the specified color (with optional opacity), with coordinates in x and y slices.
Rect makes a rectangle, centered at (x,y), with (w,h) dimensions, at the specified color and optional opacity.
Square makes a square, centered at (x,y), with width w, at the specified color and optional opacity.
StartDeck begins a slide deck.
StartSlide begins a slide.
Text places plain text aligned at (x,y), with specified font, size and color. Opacity is optional
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 (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 (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.
func (p *Deck) TextRotate(x, y float64, s, link, font string, rotation, size float64, color string, opacity ...float64)
TextRotate places rotated text
Package generate imports 3 packages (graph) and is imported by 10 packages. Updated 2020-04-22. Refresh now. Tools for package owners.