tiled

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(id string, cornerTiles []Tile, sideTiles []Tile, centerTiles []Tile, opts ...Option) icon.Generator

New creates a new tiled generator using the given set of base parameters.

This function will typically never be called by end users directly but instead be wrapped in a template specific function (such as classic.New).

Types

type Generator

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

func (*Generator) Draw

func (g *Generator) Draw(input []byte, canvas *svg.SVG)

func (*Generator) Id

func (g *Generator) Id() string

func (*Generator) Size

func (g *Generator) Size() uint

func (*Generator) Write

func (g *Generator) Write(input []byte, w io.Writer)

type Option

type Option func(g *Generator)

Option represents an option which may be passed to New in order to adjust the default settings of the generator.

func BackgroundColor

func BackgroundColor(color colorful.Color) Option

BackgroundColor selects the color of the background rectangle of the resulting image.

func Code

func Code(generator code.Generator) Option

Code selects the code generator which shall be used to create a seed code from input values.

func ColoredSides

func ColoredSides(value bool) Option

ColoredSides causes the unique sections within the image to be colored differently to make them easier to distinguish.

func ForegroundColor

func ForegroundColor(color color.Generator) Option

ForegroundColor selects a generator which decides the color which is to be applied to the entire image or its respective sections.

func ImageSize

func ImageSize(imageSize uint) Option

ImageSize selects a suitable TileSize based on the given input image size.

All image sizes must be divisible by four in order to produce accurate results.

func PermitAdjacentDuplicates

func PermitAdjacentDuplicates(value bool) Option

PermitAdjacentDuplicates selects whether the same tile may appear in adjacent areas within the resulting image.

func TileSize

func TileSize(tileSize uint) Option

TileSize customizes the default size at which each respective tile within the graphic is rendered.

func TransparentBackground

func TransparentBackground() Option

TransparentBackground disables the background coloring for the resulting image thus making it transparent where tiles did not draw geometry.

type Tile

type Tile interface {
	Draw(canvas *svg.SVG, x float64, y float64, size float64, flipX bool, flipY bool, rotations uint)
}

Tile represents an arbitrary tile implementation which renders at the given desired location

func Circle

func Circle(scale float64) Tile

Circle returns a fully circular tile with a given scale.

func Combined

func Combined(tiles ...Tile) Tile

Combined returns a tile which renders multiple tiles within a single cell.

func Donut

func Donut(outerScale float64, innerScale float64) Tile

Donut created a tile which draws a circle with a hole in the middle.

func Flipped

func Flipped(tile Tile, flipX bool, flipY bool) Tile

Flipped returns a tile which has been flipped along its X, Y axis or both.

func Rect

func Rect(offsetX float64, offsetY float64, scaleX float64, scaleY float64) Tile

Rect returns a tile which draws a simple rectangle.

func Shape

func Shape(vertices ...*shape.Vert2d) Tile

Shape creates a new tile which draws a given shape consisting of two or more vertices.

func Transform

func Transform(tile Tile, offsetX float64, offsetY float64, scale float64, rotations uint) Tile

Transform adjusts the position and scale at which a given tile is drawn.

Jump to

Keyboard shortcuts

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