render

package
v1.0.56 Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedOrientation represents an error in the unsupported orientation for rendering.
	ErrUnsupportedOrientation = errors.New("tiled/render: unsupported orientation")
	// ErrUnsupportedRenderOrder represents an error in the unsupported order for rendering.
	ErrUnsupportedRenderOrder = errors.New("tiled/render: unsupported render order")
)

Functions

This section is empty.

Types

type AnimationTile added in v1.0.7

type AnimationTile struct {
	TileImages []image.Image
	TilePos    image.Rectangle
	TilePlane  string
	Duration   uint32
}

type LayerObjects added in v1.0.7

type LayerObjects struct {
	Animation   []AnimationTile
	TileObjects []TileObject
	XCollision  map[float64][]float64
	YCollision  map[float64][]float64
}

type OrthogonalRendererEngine

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

OrthogonalRendererEngine represents orthogonal rendering engine.

func (*OrthogonalRendererEngine) GetFinalImageSize

func (e *OrthogonalRendererEngine) GetFinalImageSize() image.Rectangle

GetFinalImageSize returns final image size based on map data.

func (*OrthogonalRendererEngine) GetTilePosition

func (e *OrthogonalRendererEngine) GetTilePosition(x, y int) image.Rectangle

GetTilePosition returns tile position in image.

func (*OrthogonalRendererEngine) GetTrueTilePosition

func (e *OrthogonalRendererEngine) GetTrueTilePosition(tileRect image.Rectangle, x, y int) image.Rectangle

GetTilePosition returns tile position in image.

func (*OrthogonalRendererEngine) Init

func (e *OrthogonalRendererEngine) Init(m *tiled.Map)

Init initializes rendering engine with provided map options.

func (*OrthogonalRendererEngine) RotateTileImage

func (e *OrthogonalRendererEngine) RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image

RotateTileImage rotates provided tile layer.

type Renderer

type Renderer struct {
	Result *image.NRGBA // The image result after rendering using the Render functions.
	// contains filtered or unexported fields
}

Renderer represents an rendering engine.

func NewRenderer

func NewRenderer(m *tiled.Map) (*Renderer, error)

NewRenderer creates new rendering engine instance.

func (*Renderer) Clear

func (r *Renderer) Clear()

Clear clears the render result to allow for separation of layers. For example, you can render a layer, make a copy of the render, clear the renderer, and repeat for each layer in the Map.

func (*Renderer) RenderLayer

func (r *Renderer) RenderLayer(index int) (LayerObjects, error)

RenderLayer renders single map layer.

func (*Renderer) RenderVisibleLayers

func (r *Renderer) RenderVisibleLayers() (coll LayerObjects, e error)

RenderVisibleLayers renders all visible map layers.

func (*Renderer) SaveAsGif

func (r *Renderer) SaveAsGif(w io.Writer, options *gif.Options) error

SaveAsGif writes rendered layers as GIF image to provided writer.

func (*Renderer) SaveAsJpeg

func (r *Renderer) SaveAsJpeg(w io.Writer, options *jpeg.Options) error

SaveAsJpeg writes rendered layers as JPEG image to provided writer.

func (*Renderer) SaveAsPng

func (r *Renderer) SaveAsPng(w io.Writer) error

SaveAsPng writes rendered layers as PNG image to provided writer.

type RendererEngine

type RendererEngine interface {
	Init(m *tiled.Map)
	GetFinalImageSize() image.Rectangle
	RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image
	GetTilePosition(x, y int) image.Rectangle
	GetTrueTilePosition(tileRect image.Rectangle, x, y int) image.Rectangle
}

RendererEngine is the interface implemented by objects that provide rendering engine for Tiled maps.

type TileObject

type TileObject struct {
	TileImage image.Image
	TilePos   image.Rectangle
	TilePlane string
}

Jump to

Keyboard shortcuts

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