renderer

package
v0.0.0-...-0dfd57a Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package renderer generates info card images from data templates.

Index

Constants

This section is empty.

Variables

View Source
var (
	FaGear = '\uf013'
)
View Source
var StyleCard = Style{
	ColorDarkPrimary:  color.NRGBA{0xfa, 0xfa, 0xfa, 0xff},
	ColorPrimary:      color.NRGBA{0xff, 0xff, 0xff, 0xff},
	ColorLightPrimary: color.NRGBA{0x72, 0x72, 0x72, 0xff},
	ColorText:         color.NRGBA{0x21, 0x21, 0x21, 0xff},

	ColorAccent:        color.NRGBA{0xff, 0x52, 0x52, 0xff},
	ColorTextPrimary:   color.NRGBA{0x21, 0x21, 0x21, 0xff},
	ColorTextSecondary: color.NRGBA{0x72, 0x72, 0x72, 0xff},
	ColorDivider:       color.NRGBA{0xb6, 0xb6, 0xb6, 0xff},

	ColorSecondary: color.NRGBA{0xfa, 0xfa, 0xfa, 0xff},
}
View Source
var StyleDefault = Style{
	ColorDarkPrimary:  color.NRGBA{0x30, 0x3f, 0x9f, 0xff},
	ColorPrimary:      color.NRGBA{0x3f, 0x51, 0xb5, 0xff},
	ColorLightPrimary: color.NRGBA{0xc5, 0xca, 0xe9, 0xff},
	ColorText:         color.NRGBA{0xff, 0xff, 0xff, 0xff},

	ColorAccent:        color.NRGBA{0xff, 0x52, 0x52, 0xff},
	ColorTextPrimary:   color.NRGBA{0x21, 0x21, 0x21, 0xff},
	ColorTextSecondary: color.NRGBA{0x72, 0x72, 0x72, 0xff},
	ColorDivider:       color.NRGBA{0xb6, 0xb6, 0xb6, 0xff},

	ColorSecondary: color.NRGBA{0xfa, 0xfa, 0xfa, 0xff},
}

Functions

func LoadFont

func LoadFont(name, file string) error

Types

type BackgroundLayout

type BackgroundLayout struct {
	Image     string
	Grayscale bool
	Color     bool
}

func (*BackgroundLayout) Render

func (l *BackgroundLayout) Render(ctx *Context, bounds Rect) error

type Context

type Context struct {
	Image draw.Image
	*draw2dimg.GraphicContext
	Style Style
}

func NewContext

func NewContext() *Context

func (*Context) DrawIcon

func (ctx *Context) DrawIcon(icon rune, size, x, y float64) error

func (*Context) Render

func (ctx *Context) Render(layouts ...Layout) error

func (*Context) SaveToFile

func (ctx *Context) SaveToFile(file string) error

type Converted

type Converted struct {
	Img image.Image
	Mod color.Model
}

Converted implements image.Image, so you can pretend that it is the converted image.

func (*Converted) At

func (c *Converted) At(x, y int) color.Color

At forwards the call to the original image and then asks the color model to convert it.

func (*Converted) Bounds

func (c *Converted) Bounds() image.Rectangle

... but the original bounds

func (*Converted) ColorModel

func (c *Converted) ColorModel() color.Model

We return the new color model...

type Layout

type Layout interface {
	Render(*Context, Rect) error
}

type OutputFormat

type OutputFormat struct {
	Format string
	Width  int
	Height int
}

type OverviewLayout

type OverviewLayout struct {
	Title         string
	TitleIcon     rune
	Subtitle      string
	FootnoteLeft  string
	FootnoteRight string

	LeftColumn  Layout
	RightColumn Layout
	Background  Layout
}

func (*OverviewLayout) Render

func (l *OverviewLayout) Render(ctx *Context, bounds Rect) error

type PathLayout

type PathLayout struct {
	Path   [][]float64
	LatLng bool
}

func (*PathLayout) Render

func (l *PathLayout) Render(ctx *Context, bounds Rect) error

type Rect

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

func (Rect) Height

func (r Rect) Height() float64

func (Rect) Width

func (r Rect) Width() float64

type Renderer

type Renderer struct {
	Image   draw.Image
	Context *draw2d.GraphicContext
}

type Style

type Style struct {
	ColorDarkPrimary  color.Color
	ColorPrimary      color.Color
	ColorLightPrimary color.Color
	ColorText         color.Color

	ColorAccent        color.Color
	ColorTextPrimary   color.Color
	ColorTextSecondary color.Color
	ColorDivider       color.Color

	ColorSecondary color.Color
}

Jump to

Keyboard shortcuts

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