arduboy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnyPortKey           = "any"
	ArduboyDeviceKey     = "Arduboy"
	ArduboyFXDeviceKey   = "ArduboyFX"
	ArduboyMiniDeviceKey = "ArduboyMini"

	ResetToBootloaderWait = 1 * time.Second
	JedecVerifyWait       = 500 * time.Millisecond

	DefaultBaudRate = 57600
	RebootBaudRate  = 1200

	FlashSize              int = 32768
	FlashPageSize          int = 128
	FlashPageCount         int = FlashSize / FlashPageSize
	FXPageSize             int = 256
	FXBlockSize            int = 65536
	FxPagesPerBlock        int = FXBlockSize / FXPageSize
	EepromSize             int = 1024
	CaterinaTotalSize      int = 4096
	CaterinaStartPage      int = (FlashSize - CaterinaTotalSize) / FlashPageSize
	CathyTotalSize         int = 3072
	CathyStartPage         int = (FlashSize - CathyTotalSize) / FlashPageSize
	ScreenWidth            int = 128
	ScreenHeight           int = 64
	ScreenBytes            int = ScreenWidth * ScreenHeight / 8
	MinBootloaderWithFlash     = 13
)
View Source
const (
	Board_ArduboyLeonardo   = "Arduboy Leonardo"
	Board_ArduboyMicro      = "Arduboy Micro"
	Board_GenuinoMicro      = "Genuino Micro"
	Board_SparkfunMicro     = "Sparkfun Pro Micro 5V"
	Board_AdafruitItsyBitsy = "Adafruit ItsyBitsy 5V"
)
View Source
const (
	FxHeaderStartString = "ARDUBOY"

	FxHeaderLength      = 256                                         // The flashcart slot header length in bytes
	FxHeaderMetaSize    = 199                                         // Length of the metadata section
	FxHeaderImageLength = 1024                                        // The flashcart slot title image length in bytes
	FxPreamblePages     = (FxHeaderLength + FxHeaderImageLength) >> 8 // Page size of entire preamble (includes title)
	FxSaveAlignment     = 4096                                        // Saves must be aligned to this size

	FxHeaderCategoryIndex     = 7  // "Index into slot header for" category (1 byte)
	FxHeaderPreviousPageIndex = 8  // "" previous slot page (2 bytes)
	FxHeaderNextPageIndex     = 10 // "" next slot page (2 bytes)
	FxHeaderSlotSizeIndex     = 12 // "" slot size. (2 bytes)
	FxHeaderProgramSizeIndex  = 14 // "" program size (1 byte, factor of 128)
	FxHeaderProgramPageIndex  = 15 // "" starting page of program (2 bytes)
	FxHeaderDataPageIndex     = 17 // "" starting page of data (2 bytes)
	FxHeaderSavePageIndex     = 19 // "" starting page of save (2 bytes)
	FxHeaderDataSizeIndex     = 21 // "" data segment size (2 bytes, factor of 256)
	FxHeaderHashIndex         = 25 // "" hash (32 bytes)
	FxHeaderHashLength        = 32
	FxHeaderMetaIndex         = 57 // "" metadata
)
View Source
const (
	LEDCtrlBtnOff = 0x80
	LEDCtrlRGB    = 0x40
	LEDCtrlRxTx   = 0x20
	LEDCtrlRxOn   = 0x10
	LEDCtrlTxOn   = 0x08
	LEDCtrlGrOn   = 0x04
	LEDCtrlRdOn   = 0x02
	LEDCtrlBlOn   = 0x01
)
View Source
const FlashcartMetaTemplate = `` /* 1058-byte string literal not displayed */
View Source
const (
	HexLineLength = 16
)

Variables

View Source
var (
	ARDUBOYFXEnableBytes    = []byte{0x59, 0x98}
	ARDUBOYFXDisableBytes   = []byte{0x59, 0x9a}
	ARDUBOYMINIEnableBytes  = []byte{0x72, 0x98} //, 0x0e, 0x94}
	ARDUBOYMINIDisableBytes = []byte{0x72, 0x9a} //, 0x08, 0x95}
	ARDUBOYCallFollowBytes  = [][]byte{
		{0x08, 0x95},
		{0x0e, 0x94},
		{0x83, 0xe0, 0x0e, 0x94},
	}
)
View Source
var JedecManufacturerKeys = map[int]string{
	0x01: "Spansion",
	0x14: "Cypress",
	0x1C: "EON",
	0x1F: "Adesto(Atmel)",
	0x20: "Micron",
	0x37: "AMIC",
	0x9D: "ISSI",
	0xC2: "General Plus",
	0xC8: "Giga Device",
	0xBF: "Microchip",
	0xEF: "Winbond",
}

A mapping from identifiers returned from the bootloader to manufacturer strings. Pulled from Mr.Blinky's Python Utilities: https://github.com/MrBlinky/Arduboy-Python-Utilities/blob/main/fxdata-upload.py

View Source
var VidPidTable = map[string]BasicBoardInfo{

	"VID:PID=2341:0036": {Name: Board_ArduboyLeonardo, IsBootloader: true},
	"VID:PID=2341:8036": {Name: Board_ArduboyLeonardo, IsBootloader: false},
	"VID:PID=2A03:0036": {Name: Board_ArduboyLeonardo, IsBootloader: true},
	"VID:PID=2A03:8036": {Name: Board_ArduboyLeonardo, IsBootloader: false},

	"VID:PID=2341:0037": {Name: Board_ArduboyMicro, IsBootloader: true},
	"VID:PID=2341:8037": {Name: Board_ArduboyMicro, IsBootloader: false},
	"VID:PID=2A03:0037": {Name: Board_ArduboyMicro, IsBootloader: true},
	"VID:PID=2A03:8037": {Name: Board_ArduboyMicro, IsBootloader: false},

	"VID:PID=2341:0237": {Name: Board_GenuinoMicro, IsBootloader: true},
	"VID:PID=2341:8237": {Name: Board_GenuinoMicro, IsBootloader: false},

	"VID:PID=1B4F:9205": {Name: Board_SparkfunMicro, IsBootloader: true},
	"VID:PID=1B4F:9206": {Name: Board_SparkfunMicro, IsBootloader: false},

	"VID:PID=239A:000E": {Name: Board_AdafruitItsyBitsy, IsBootloader: true},
	"VID:PID=239A:800E": {Name: Board_AdafruitItsyBitsy, IsBootloader: false},
}

A mapping from VID/PID values to basic information about the board. Pulled from Mr.Blinky's Python Utilities: https://github.com/MrBlinky/Arduboy-Python-Utilities/blob/main/fxdata-upload.py

Functions

func AddressCommandFlashAddress

func AddressCommandFlashAddress(address uint16) []byte

Produce the command for setting the flash address based on true byte offset

func AddressCommandFlashPage

func AddressCommandFlashPage(page uint16) []byte

Produce the command for setting the address before reading (page aligned)

func AddressCommandFlashcartBlock

func AddressCommandFlashcartBlock(block uint16) []byte

func AddressCommandFlashcartPage

func AddressCommandFlashcartPage(page uint16) []byte

Produce the command for setting the address before reading flashcart data (flashcart page aligned)

func AddressCommandRaw

func AddressCommandRaw(address uint16) []byte

Produce the command for setting the address before reading (raw address)

func BinToHex

func BinToHex(data []byte, writer io.Writer) error

Convert given byte blob to hex. Does NOT modify the data in any way

func CreateReadFlashcartBuffer added in v0.3.0

func CreateReadFlashcartBuffer() []byte

Create the optimal buffer needed for ReadFlashcartInto

func DeleteEeprom

func DeleteEeprom(sercon io.ReadWriter) error

Delete the entire eeprom

func EchoSpaceControls added in v0.3.0

func EchoSpaceControls(s string) string

func ExitBootloader

func ExitBootloader(sercon io.ReadWriteCloser) error

Exit the given bootloader

func FillStringArray

func FillStringArray(strings []string, data []byte) (int, int)

Fill the given data byte buffer with as much of the strings contained within the strings parameter. Returns the total amount of strings written and the amount truncated from the last written string

func FindStringDiff added in v0.3.0

func FindStringDiff(a string, b string) error

func FxHeaderStartBytes

func FxHeaderStartBytes() []byte

func Get2ByteValue

func Get2ByteValue(data []byte, index int) uint16

Read a 2 byte value in the middle of data

func HexToBin

func HexToBin(reader io.Reader) ([]byte, error)

Convert hex within given reader to full byte blob. Does NOT modify the data in any way (no padding/etc)

func ImageToPaletted

func ImageToPaletted(img image.Image, whiteThreshold uint8, alphaThreshold uint8) ([]byte, int, int)

Convert real image to paletted image, no resizing

func MapHeaderResult

func MapHeaderResult(result *[]HeaderCategory, header *FxHeader) (*string, error)

Given a header, store it in the appropriate place within the 'result' category list. This is a common operation for flashcart metadata scanning. Gives you the location where you can store the image (since both have the generic item)

func Md5String

func Md5String(data []byte) string

Produce an md5 string from given data (a simple shortcut)

func PalettedToCode added in v0.3.0

func PalettedToCode(ptiles [][]byte, config *TileConfig, computed *TileConfigComputed) (string, error)

Convert the given paletted image to the header data + fxdata (returns a tuple). Taken almost directly from https://github.com/MrBlinky/Arduboy-Python-Utilities/blob/main/image-converter.py THIS FUNCTION CAN BE MEMORY INTENSIVE! The entire code file is buffered in memory!

func PalettedToImage

func PalettedToImage(raw []byte, width int, height int, black color.Color, white color.Color, format string, writer io.Writer) error

Convert a paletted raw to an image of the given format. Possible values are gif, png, bmp, jpg. Transparency is possible if the right colors are chosen, but only two colors are allowed

func PalettedToImageTitleBW added in v0.2.0

func PalettedToImageTitleBW(raw []byte, format string) ([]byte, error)

Convert a paletted image to a real image in the given format. Don't bother with a writer, since titles are so small

func PalettedToRaw

func PalettedToRaw(paletted []byte, width int, height int) ([]byte, []byte, error)

Convert a paletted image to a raw arduboy format

func PalettedToRawTitle added in v0.2.0

func PalettedToRawTitle(raw []byte) ([]byte, error)

func ParseStringArray

func ParseStringArray(data []byte) []string

Parse as many null-terminated strings as possible out of the data. Useful for the header "metadata"

func RawImageToPaletted added in v0.3.0

func RawImageToPaletted(raw io.Reader, whiteThreshold uint8, alphaThreshold uint8) ([]byte, int, int, error)

If you haven't already decoded the image, we can do that for you

func RawImageToPalettedTitle added in v0.3.0

func RawImageToPalettedTitle(raw io.Reader, whiteThreshold uint8) ([]byte, error)

Resize and downscale the given image into a paletted image with arduboy dimensions. The whiteThreshold is the start of what is considered "white". Everything else is black

func RawToPaletted

func RawToPaletted(raw []byte, width int, height int) ([]byte, error)

Convert a raw arduboy image (in arduboy format) to "regular" grayscale using the given black + white points

func RawToPalettedTitle added in v0.2.0

func RawToPalettedTitle(raw []byte) ([]byte, error)

func ReadEeprom

func ReadEeprom(sercon io.ReadWriter) ([]byte, error)

Read the entire flash memory, including bootloader. This is ironically faster than just reading the sketch

func ReadEepromCommand

func ReadEepromCommand(length uint16) []byte

Produce command for reading an amount from eeprom (probably the whole thing though)

func ReadFlash

func ReadFlash(sercon io.ReadWriter) ([]byte, error)

Read the entire flash memory, including bootloader. This is ironically faster than just reading the sketch

func ReadFlashCommand

func ReadFlashCommand(length uint16) []byte

Produce the command for reading some amount from the current address

func ReadFlashcart

func ReadFlashcart(sercon io.ReadWriter, address int, length int) ([]byte, error)

Read portion of flashcart at given address, allocating a new slice every time. Very much not performant; prefer ReadFlashcartOptimized if possible

func ReadFlashcartCommand

func ReadFlashcartCommand(length uint16) []byte

Produce command for reading an amount from the flashcart

func ReadFlashcartInto

func ReadFlashcartInto(sercon io.ReadWriter, address int, length int, output io.Writer, readbuf []byte) error

Read any portion of flashcart at given address. Not performant at all

func ReadFlashcartOptimized added in v0.3.0

func ReadFlashcartOptimized(sercon io.ReadWriter, page uint16, length uint16) ([]byte, error)

Read flashcart at simple page boundaries, creating a new slice every time

func ReadFlashcartOptimizedInto added in v0.3.0

func ReadFlashcartOptimizedInto(sercon io.ReadWriter, page uint16, data []byte) error

Read flashcart at simple page boundaries and in less-than-16bit lengths. Function will NOT throw an error if data is too long, it will simply only read up to 65k

func ReadSketch

func ReadSketch(sercon io.ReadWriter, trim bool) ([]byte, error)

Read the entire sketch, without the bootloader. Also trims the sketch

func ReadWholeFlashcart

func ReadWholeFlashcart(sercon io.ReadWriter, output io.Writer, logProgress bool) (int, int, error)

Read the entire flashcart slot-by-slot and write it out to the 'output' writer. This is a "smart" reader that scans through slots reading them one by one. This is slightly slower than mindless block reading, but can be overall faster because it's not reading the entire flash memory (plus you can get more interesting logging + data). NOTE: DOES NOT CHECK FOR FLASHCART EXISTENCE!

func ReadWriteCommandRaw

func ReadWriteCommandRaw(mode rune, length uint16, device rune) []byte

func RenderFlashcartMeta

func RenderFlashcartMeta(categories []HeaderCategory, deviceId string, destination io.Writer) error

func ResetRgbButtonState

func ResetRgbButtonState(sercon io.ReadWriter) error

func RgbButtonCommand

func RgbButtonCommand(data uint8) []byte

func RgbButtonCommandRaw

func RgbButtonCommandRaw(data uint8) []byte

func ScanFlashcart

func ScanFlashcart(sercon io.ReadWriter, headerFunc func(io.ReadWriter, *FxHeader, int, int) error,
	flashRate int, flashColor uint8) (int, int, error)

Scan through the flashcart, calling the given function for each header parsed. returns the total size of the flashcart and the number of headers read. The function also receives the current header address and number of headers previously read (starts with 0). NOTE: DOES NOT CHECK FOR FLASHCART EXISTENCE!!!

func ScanFlashcartFile

func ScanFlashcartFile(data io.ReadSeeker, headerFunc func(io.ReadSeeker, *FxHeader, int) error) (int, error)

Same as ScanFlashcart but for a file / other file-like readerseeker. No address given, as that can be determined from the ReadSeeker given

func ScanFlashcartSize added in v0.3.0

func ScanFlashcartSize(sercon io.ReadWriter) (int, int, error)

A wrapper for ScanFlashcart which only returns the basic flashcart size in bytes and slots

func SetRgbButtonState

func SetRgbButtonState(sercon io.ReadWriter, state uint8) error

func SetRgbEnabledGlobal

func SetRgbEnabledGlobal(enabled bool)

func TrimUnused

func TrimUnused(data []byte, blocksize int) []byte

Remove unused sections from the end of the byte array. In these files, sections of 0xFF represent unused data.

func Uint32ToColor

func Uint32ToColor(c uint32) color.Color

func VidPidString

func VidPidString(vid string, pid string) string

Construct 'standardized' VID:PID string (the same format python uses, just in case)

func Write2ByteValue

func Write2ByteValue(value uint16, data []byte, index int)

Write a 2 byte value directly into the middle of data

func WriteEeprom

func WriteEeprom(sercon io.ReadWriter, data []byte) error

Write the given eeprom to the device. This may take a while

func WriteEepromCommand

func WriteEepromCommand(length uint16) []byte

func WriteFlashCommand

func WriteFlashCommand(length uint16) []byte

func WriteFlashcart added in v0.3.0

func WriteFlashcart(sercon io.ReadWriter, address int, data []byte, logProgress bool) (int, int, error)

Write any arbitrary amount of data to the flash, perserving any data surrounding it (since writing flashes the entire 65k block). Return the actual address it started writing to, and the total write size

func WriteFlashcartCommand

func WriteFlashcartCommand(length uint16) []byte

func WriteHex

func WriteHex(sercon io.ReadWriter, rawSketch io.Reader, fullClear bool) ([]byte, []bool, error)

Writing a sketch the "right way" is WEIRD because of the intel hex format. The hex file indicates various addresses to write data to, not a giant data blob. In theory, you could supply this function with hex that writes only every other page, or only some pages in the middle. As such, you must provide the raw sketch, not actual binary data, since there might be holes (there most likely aren't). This function reads the entire existing sketch area (everything minus the bootloader) into memory, applies the hex modifications on top, then writes only the modified pages (smallest writable unit) back to the flash memory. We could technically ignore the hex standard and assume no sketch will ever have holes and simplify this dramatically, but I wanted this to be as correct as possible. Alternatively, to write an "arduboy" sketch program, set fullClear to true and you don't have to worry about any weirdness

func WriteWholeFlashcart

func WriteWholeFlashcart(sercon io.ReadWriter, input io.Reader, verify bool, logProgress bool) (int, error)

Write an entire flashcart starting at the normal address and going to the end. Does not care about any existing data on the flashcart. NOTE: DOES NOT CHECK FOR FLASHCART EXISTENCE OR SIZE

Types

type BasicBoardInfo

type BasicBoardInfo struct {
	Name         string
	IsBootloader bool
}

type BasicDeviceInfo

type BasicDeviceInfo struct {
	VidPid       string
	Port         string
	Product      string
	BoardType    string
	IsBootloader bool
}

func ConnectWithBootloader

func ConnectWithBootloader(port string) (io.ReadWriteCloser, *BasicDeviceInfo, error)

Connect to given port and force bootloader. Accepts "any" as a special port identifier, will connect to "first" connection found. If exact port is given and no bootloader specified, will reboot device and NOT connect, since it is not always possible to reconnect on the same port. If "any" given, will attempt a reconnect after 2 seconds

func GetBasicDevices

func GetBasicDevices() ([]BasicDeviceInfo, error)

Retrieve a list of all connected arduboys and any information that can be parsed without actually connected to the ports

func (*BasicDeviceInfo) SmallString

func (device *BasicDeviceInfo) SmallString() string

type BootloaderInfo

type BootloaderInfo struct {
	Device     string
	SoftwareId string
	Startpage  int
	Length     int
	IsCaterina bool
	Version    int
	MD5        string
}

func GetBootloaderInfo

func GetBootloaderInfo(sercon io.ReadWriter) (*BootloaderInfo, error)

Pull as much bootloader information as possible without overstepping into JEDEC or whatever

func (*BootloaderInfo) GetJedecInfo

func (info *BootloaderInfo) GetJedecInfo(sercon io.ReadWriter, verify bool) (*JedecInfo, error)

Ask device for JEDEC info. NOTE: this function will block for some time (500ms?) while it verifies the jedec ID! (if you ask for it).

type ExtendedDeviceInfo

type ExtendedDeviceInfo struct {
	Basic        *BasicDeviceInfo
	Bootloader   *BootloaderInfo
	Jedec        *JedecInfo
	HasFlashcart bool
}

func QueryDevice

func QueryDevice(device *BasicDeviceInfo, sercon io.ReadWriteCloser, verify bool) (*ExtendedDeviceInfo, error)

Get extended device info from the given information

type FxHeader

type FxHeader struct {
	Category     uint8
	PreviousPage uint16
	NextPage     uint16
	SlotPages    uint16
	ProgramPages uint8
	ProgramStart uint16
	DataStart    uint16
	SaveStart    uint16
	DataPages    uint16

	Sha256 string

	// Metadata
	Title     string
	Version   string
	Developer string
	Info      string
}

All data in the header of an fx slot (JUST the header, not the image)

func ParseHeader

func ParseHeader(data []byte) (*FxHeader, []byte, error)

Parse the header out of a byte slice. Will throw an error on slice too small or on header "not a header". Byte array returned is the slice without the header anymore

func (*FxHeader) IsCategory

func (h *FxHeader) IsCategory() bool

func (*FxHeader) MakeHeader

func (header *FxHeader) MakeHeader() ([]byte, error)

Generate the bytes you can write to the flashcart

type HeaderCategory

type HeaderCategory struct {
	Title string
	Info  string
	Image string
	Slots []*HeaderProgram
}

func ScanFlashcartFileMeta

func ScanFlashcartFileMeta(data io.ReadSeeker, getImages bool) ([]HeaderCategory, error)

Scrape metadata out of a file flashcart, same as ScanFlashcartMeta

func ScanFlashcartMeta

func ScanFlashcartMeta(sercon io.ReadWriter, getImages bool) ([]HeaderCategory, error)

Scrape just the metadata out of the flashcart. Optionally pull images (much slower)

type HeaderProgram

type HeaderProgram struct {
	Title     string
	Version   string
	Developer string
	Info      string
	Sha256    string
	TotalSize int
	Image     string
}

type JedecInfo

type JedecInfo struct {
	ID           string
	Capacity     int
	Manufacturer string
}

func (*JedecInfo) FitsFlashcart

func (j *JedecInfo) FitsFlashcart(size int) bool

Whether this jedec info will fit a flashcart of given size. there are caveats to fitting a flashcart (it must end with an empty page and whatever)

func (*JedecInfo) ValidateFitsFxData added in v0.3.0

func (j *JedecInfo) ValidateFitsFxData(fsize int, dsize int, noBlockOverlap bool) error

Whether the flashcart of fsize could fit fxdata of dsize at the end. Can also specify whether it would fit without block overlap, simplifying the writing process (no reads required)

type NotEnoughDataError

type NotEnoughDataError struct {
	Expected int
	Found    int
}

func (*NotEnoughDataError) Error

func (m *NotEnoughDataError) Error() string

type NotHeaderError

type NotHeaderError struct{}

func (*NotHeaderError) Error

func (m *NotHeaderError) Error() string

type ReadWriteErrorPass

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

func (*ReadWriteErrorPass) IsPass

func (rwep *ReadWriteErrorPass) IsPass() error

func (*ReadWriteErrorPass) Read

func (rwep *ReadWriteErrorPass) Read(b []byte) (int, error)

A special read function which will skip if an error is present in the struct, and which will read until it fills the entire given byte slice (blocking)

func (*ReadWriteErrorPass) ReadPass

func (rwep *ReadWriteErrorPass) ReadPass(b []byte) int

func (*ReadWriteErrorPass) Write

func (rwep *ReadWriteErrorPass) Write(b []byte) (int, error)

A special write function which will skip if an error is present in the struct, and which will write until it has written the entire buffer contents (blocking)

func (*ReadWriteErrorPass) WritePass

func (rwep *ReadWriteErrorPass) WritePass(b []byte) int

type ReadWritePasser

type ReadWritePasser interface {
	io.ReadWriter
	ReadPass([]byte) int
	WritePass([]byte) int
	IsPass() error
}

type RemoveFirstLines

type RemoveFirstLines struct {
	LinesToIgnore int
	Writer        io.Writer
}

A writer wrapper which removes the first few lines of output

func (*RemoveFirstLines) Write

func (fhf *RemoveFirstLines) Write(data []byte) (int, error)

Skip everything up to and including the first N newlines

type SketchAnalysis

type SketchAnalysis struct {
	OverwritesCaterina bool
	OverwritesCathy    bool // If this happens, sketch is too large. Probably not used...
	TotalPages         int
	TrimmedData        []byte
	DetectedDevice     string
}

func AnalyzeSketch

func AnalyzeSketch(bindata []byte, bootloader bool) SketchAnalysis

Compute various important attributes of the given flash data. It could be a sketch or a bootloader

type TileConfig added in v0.2.0

type TileConfig struct {
	Width         int    // Width of tile (0 means use all available width)
	Height        int    // Height of tile (0 means use all available height)
	Spacing       int    // Spacing between tiles (including on edges)
	UseMask       bool   // Whether to use transparency as a data mask
	SeparateMask  bool   // Separate the mask from the data
	NoDimensions  bool   // Don't output dimension variables in data
	NoPreamble    bool   // Don't generate the preamble (includes, etc)
	WindowsFormat bool   // Windows newlines (\r\n)
	Name          string // Name of the sprite variables to generate
}

Configuration for tile / code generation

func (*TileConfig) Expand added in v0.2.0

func (t *TileConfig) Expand(width int, height int) *TileConfigComputed

Calculate individaul sprite width, height, horizontal count, and vertical count

type TileConfigComputed added in v0.2.0

type TileConfigComputed struct {
	SpriteWidth  int // Calculated width of each sprite
	SpriteHeight int // Calculated height of each sprite
	HFrames      int // How many tiles across
	VFrames      int // How many tiles vertical
	StartX       int // Where to start reading tiles within the image
	StartY       int // Where to start reading tiles within the image
	StrideX      int // How far to move through the image to find the next tile
	StrideY      int // How far to move through the image to find the next tile
}

Extra computed fields when we know more about the image we're applying the tile config to

func SplitImageToTiles added in v0.2.0

func SplitImageToTiles(rawimage io.Reader, config *TileConfig) ([]*image.NRGBA, *TileConfigComputed, error)

Split the given image into linear tiles based on the given tile config. returns the array of tile images, each in NRGBA format

func (*TileConfigComputed) ValidateForCode added in v0.2.0

func (c *TileConfigComputed) ValidateForCode() error

Ensure computed tile config is valid. Check returned error for nil

func (*TileConfigComputed) ValidateForFx added in v0.2.0

func (c *TileConfigComputed) ValidateForFx() error

Ensure computed tile config is valid for writing to fx.

func (*TileConfigComputed) ValidateGeneral added in v0.2.0

func (c *TileConfigComputed) ValidateGeneral() error

Jump to

Keyboard shortcuts

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