Documentation ¶
Index ¶
- Constants
- Variables
- func Draw(pc PatternContext, texts []*string, patternDraw BgFn)
- func DrawBgCircles(c PatternContext)
- func DrawBgLines(c PatternContext)
- func DrawHexagon(c PatternContext)
- func DrawHexagon2(c PatternContext)
- func DrawRect(c PatternContext)
- func DrawRectRand(c PatternContext)
- func DrawT(dc *gg.Context, t Text, textMaxWidth float64)
- func GenerateBanner(i Input)
- type Alg
- type AlgType
- type BgFn
- type DeltaCalculation
- type DescProvider
- type InpData
- type Input
- type Palette
- type PaletteGenerator
- type PaletteInfo
- type PaletteType
- type PatternContext
- type Point
- type Rect
- type RectGenerator
- type Size
- type Text
Constants ¶
const DEF_ALG = 5
const DEF_HEIGHT = 600
const DEF_OUT = "out.png"
const DEF_PAL = Warm
const DEF_SUB = "this time about really important things"
const DEF_TILE = 30
const DEF_TITLE = "My blogpost"
const DEF_WIDTH = 800
const DEF_WITH_TEXT = false
const FONT_FILE = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
Variables ¶
var PainterAlgs = map[AlgType]Alg{ RandomRect: {DrawRectRand, "random rectangles", gridGenerator}, RandomRectOffset: {DrawRectRand, "random rectangles with offset", gridDeltaGenerator}, PlainColor: {DrawRect, "plain color", plainGenerator}, ConcentricCircles: {DrawBgCircles, "concentric circles", gridGenerator}, ConcentricCirclesOffset: {DrawBgCircles, "concentric circles offset", gridDeltaGenerator}, HorizontalLines: {DrawBgLines, "random horizontal lines", linesRandomGenerator}, RandomHexagons: {DrawHexagon, "random hexagons", gridGenerator}, RandomHexagonsOffset: {DrawHexagon2, "random hexagons with offset", gridHexDeltaGenerator}, }
array of identifiers presented to the user to Alg struct
var PaletteInfos = map[PaletteType]PaletteInfo{ Warm: {colorful.WarmPalette, "Warm"}, Happy: {colorful.HappyPalette, "Happy"}, Hue: {HuePalette, "Hue"}, }
Functions ¶
func Draw ¶
func Draw(pc PatternContext, texts []*string, patternDraw BgFn)
Draws with pc as PatternContext, filling background with patternDraw and using Textx.
func DrawBgCircles ¶
func DrawBgCircles(c PatternContext)
Single tile painter: draws concentric circles
func DrawBgLines ¶
func DrawBgLines(c PatternContext)
func DrawHexagon2 ¶
func DrawHexagon2(c PatternContext)
here c.size is the size of the rectangle, not the tile
func DrawRectRand ¶
func DrawRectRand(c PatternContext)
Draws rect of size with random color of the palette
func GenerateBanner ¶
func GenerateBanner(i Input)
Types ¶
type Alg ¶
type Alg struct {
// contains filtered or unexported fields
}
struct representing drawing algorithm fn - function BgFn desc - description displayed when -h option was given pg - function that generates Rects for drawing tile
type BgFn ¶
type BgFn = func(PatternContext)
type DeltaCalculation ¶
Function type: calculation of dx and dy
For given column and row number in a grid returns dx and dy used to calculate top-left position of a next tile
type DescProvider ¶
type DescProvider interface {
Desc() string
}
type Input ¶
type Input struct { W *int H *int Texts []*string AlgIdx *int TileSize *float64 Pt *int OutName *string }
func GetInput ¶
func GetInput() Input
Parses commandline parameters and gives Input object with fields initialized with provided values (or defaults) TODO - sanitize input
func InputFlagSet ¶
type Palette ¶
type Palette = []colorful.Color
func DefaultPalette ¶
func DefaultPalette(t PaletteType, n int) Palette
func GenPaletteOf ¶
func GenPaletteOf(t PaletteType, n int) Palette
func HuePalette ¶
type PaletteGenerator ¶
type PaletteInfo ¶
type PaletteInfo struct { Generator PaletteGenerator Desc string }
type PatternContext ¶
type PatternContext struct {
// contains filtered or unexported fields
}
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point struct, represents location inside drawing area
type Rect ¶
type Rect struct {
// contains filtered or unexported fields
}
Represents rectangle used to draw a tile
type RectGenerator ¶
p - top left corner of canvas s - size of canvas ts - tile size