maps

package
v0.0.0-...-81a7bf7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: ISC Imports: 6 Imported by: 0

README

maps

-- import "vimagination.zapto.org/minecraft/maps"

Usage

var (
	ErrInvalidDimensions = errors.New("cannot encode an image with the given dimensions")
)

Errors

func BlockColor
func BlockColor(b minecraft.Block) color.Color

BlockColor is the standard block-to-colour func

func Config
func Config(r io.Reader) (image.Config, error)

Config reader the configuration for an uncompressed Minecraft map.

Minecraft maps are gzip compressed, so the reader given to this func should be wrapped in gzip.NewReader.

func Decode
func Decode(r io.Reader) (image.Image, error)

Decode takes a reader for an uncompressed Minecraft map.

Minecraft maps are gzip compressed, so the reader given to this func should be wrapped in gzip.NewReader.

func Encode
func Encode(w io.Writer, i image.Image) error

Encode writes an image an as uncompressed Minecraft map.

As Minecraft expects the map to be gzip compressed, the Writer sohuld be the wrapped in gzip.NewWriter

type Encoder
type Encoder struct {
	Scale, Dimension int8
	CenterX, CenterZ int32
}

Encoder lets you specify options for the Minecraft map

func (*Encoder) Encode
func (e *Encoder) Encode(w io.Writer, im image.Image) error

Encode writes an image an as uncompressed Minecraft map.

As Minecraft expects the map to be gzip compressed, the Writer sohuld be the wrapped in gzip.NewWriter

type Image
type Image struct {
}

Image represents a Minecraft Map

func NewMap
func NewMap(l *minecraft.Level, bounds image.Rectangle, options ...Option) Image

NewMap creates an image from a Minecraft level.

func (Image) At
func (i Image) At(x, z int) color.Color

At returns the colour at the specified coords

func (Image) Bounds
func (i Image) Bounds() image.Rectangle

Bounds returns the dimensions of the map

func (Image) ColorModel
func (Image) ColorModel() color.Model

ColorModel returns the palette for the map

type Option
type Option func(*Image)

Option represents a optional parameter for a map type

func ColorFunc
func ColorFunc(c func(minecraft.Block) color.Color) Option

ColorFunc is an option for NewMap that specifies what colour blocks are painted as.

func FixedY
func FixedY(y int32) Option

FixedY is an options to fix the Y-coord of the blocks to be read. By default the highest, non-transparent block is usedd.

func Scale
func Scale(s uint8) Option

Scale sets the scale the map is to be rendered at.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDimensions = errors.New("cannot encode an image with the given dimensions")
)

Errors

Functions

func BlockColor

func BlockColor(b minecraft.Block) color.Color

BlockColor is the standard block-to-colour func

func Config

func Config(r io.Reader) (image.Config, error)

Config reader the configuration for an uncompressed Minecraft map.

Minecraft maps are gzip compressed, so the reader given to this func should be wrapped in gzip.NewReader.

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode takes a reader for an uncompressed Minecraft map.

Minecraft maps are gzip compressed, so the reader given to this func should be wrapped in gzip.NewReader.

func Encode

func Encode(w io.Writer, i image.Image) error

Encode writes an image an as uncompressed Minecraft map.

As Minecraft expects the map to be gzip compressed, the Writer sohuld be the wrapped in gzip.NewWriter

Types

type Encoder

type Encoder struct {
	Scale, Dimension int8
	CenterX, CenterZ int32
}

Encoder lets you specify options for the Minecraft map

func (*Encoder) Encode

func (e *Encoder) Encode(w io.Writer, im image.Image) error

Encode writes an image an as uncompressed Minecraft map.

As Minecraft expects the map to be gzip compressed, the Writer sohuld be the wrapped in gzip.NewWriter

type Image

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

Image represents a Minecraft Map

func NewMap

func NewMap(l *minecraft.Level, bounds image.Rectangle, options ...Option) Image

NewMap creates an image from a Minecraft level.

func (Image) At

func (i Image) At(x, z int) color.Color

At returns the colour at the specified coords

func (Image) Bounds

func (i Image) Bounds() image.Rectangle

Bounds returns the dimensions of the map

func (Image) ColorModel

func (Image) ColorModel() color.Model

ColorModel returns the palette for the map

type Option

type Option func(*Image)

Option represents a optional parameter for a map type

func ColorFunc

func ColorFunc(c func(minecraft.Block) color.Color) Option

ColorFunc is an option for NewMap that specifies what colour blocks are painted as.

func FixedY

func FixedY(y int32) Option

FixedY is an options to fix the Y-coord of the blocks to be read. By default the highest, non-transparent block is usedd.

func Scale

func Scale(s uint8) Option

Scale sets the scale the map is to be rendered at.

Jump to

Keyboard shortcuts

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