### Go Tiled Library Examples Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.8.0/example This section provides examples for using the go-tiled library, a Go package for working with Tiled map editor files. It demonstrates how to load and interact with Tiled map data structures in Go. ```go package example // This package provides examples for the go-tiled library. // It demonstrates how to load and use Tiled map data in Go applications. // For detailed usage, refer to the specific example files within this directory. ``` -------------------------------- ### Install go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Installs the go-tiled package using the go get command. It also mentions how to update the package using `go get -u` and the behavior with Go modules. ```go go get github.com/lafriks/go-tiled ``` -------------------------------- ### Get Documentation with godoc Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Provides the command to fetch detailed documentation for the go-tiled package using the `godoc` tool. ```go godoc github.com/lafriks/go-tiled ``` -------------------------------- ### Go Programming Language Resources Source: https://pkg.go.dev/github.com/lafriks/go-tiled/example This section provides links to essential resources for learning and using the Go programming language. It covers effective coding practices, user manuals, standard library documentation, and release notes. ```go // Effective Go: Tips for writing clear, performant, and idiomatic Go code // Go User Manual: A complete introduction to building software with Go // Standard library: Reference documentation for Go's standard library // Release Notes: Learn what's new in each Go release ``` -------------------------------- ### Go Package Documentation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/example%40v0.2 This entry provides general documentation for the 'example' package in Go. It outlines the package's purpose, its relationship to the main 'go-tiled' library, and its role in demonstrating functionalities. It also includes links to related resources such as package versions, licenses, and the main content of the go.dev website. ```go package example // This package demonstrates the usage of the go-tiled library. // It provides examples of how to load, manipulate, and save Tiled map files. // For more information, refer to the official go-tiled documentation and the Go project website. ``` -------------------------------- ### Go Community and Connection Source: https://pkg.go.dev/github.com/lafriks/go-tiled/example This section details various ways to connect with the Go programming community. It includes links to recorded talks, meetups, conferences, the official Go blog, and project updates, as well as social media and Q&A platforms. ```go // Recorded Talks: Videos from prior events // Meetups: Meet other local Go developers // Conferences: Learn and network with Go developers from around the world // Go blog: The Go project's official blog. // Go project: Get help and stay informed from Go // Get connected: Google Groups, GitHub, Twitter, Reddit, Slack, Stack Overflow ``` -------------------------------- ### tmx2img Command Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.6.0/example/tmx2img The tmx2img command is a Go program that takes a Tiled map file as input and generates an image representation of it. It utilizes the go-tiled library for parsing TMX files and rendering them. Ensure you have the go-tiled library installed as a dependency. ```go package main import ( "flag" "fmt" "image/png" "os" "github.com/lafriks/go-tiled" ) func main() { flag.Parse() if flag.NArg() != 1 { fmt.Fprintf(os.Stderr, "Usage: %s \n", os.Args[0]) os.Exit(1) } tmxFile := flag.Arg(0) // Load the TMX map mapData, err := tiled.LoadFromFile(tmxFile) if err != nil { fmt.Fprintf(os.Stderr, "Error loading TMX file: %v\n", err) os.Exit(1) } // Create an image from the map img, err := mapData.Render() if err != nil { fmt.Fprintf(os.Stderr, "Error rendering map: %v\n", err) os.Exit(1) } // Save the image as PNG outFile := "output.png" out, err := os.Create(outFile) if err != nil { fmt.Fprintf(os.Stderr, "Error creating output file: %v\n", err) os.Exit(1) } if err := png.Encode(out, img); err != nil { fmt.Fprintf(os.Stderr, "Error encoding PNG: %v\n", err) os.Exit(1) } fmt.Printf("Successfully rendered map to %s\n", outFile) } ``` -------------------------------- ### Go Tiled Package Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.14 This snippet provides a general overview of the go-tiled package, its purpose, and links to related resources like versions, licenses, and import information. It's a starting point for understanding the library's context within the Go ecosystem. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### MIT License Source: https://pkg.go.dev/github.com/lafriks/go-tiled/example The MIT License grants permission to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software. It requires the copyright notice and permission notice to be included in all copies or substantial portions of the Software. The software is provided 'AS IS' without warranty. ```text MIT License Copyright (c) 2017 Lauris Bukšis-Haberkorns Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### Go Package Documentation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.8 This section provides links to various Go documentation resources, including effective Go practices, the Go user manual, standard library references, and release notes. It aims to guide developers in writing idiomatic and efficient Go code. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### Go Package Documentation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.6 This section provides an overview of the go-tiled package, including links to discover packages, main versions, licenses, imports, and who imports this package. It serves as a starting point for understanding the module's structure and dependencies. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### Go Community and Project Information Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.13.0/cmd This section offers resources for engaging with the Go community and staying informed about the Go project. It includes links to talks, meetups, conferences, the official Go blog, and various channels for getting help and staying connected. ```go // Recorded Talks: Videos from prior Go events // https://go.dev/talks/ // Meetups: Meet other local Go developers // https://www.meetup.com/pro/go // Conferences: Learn and network with Go developers from around the world // https://github.com/golang/go/wiki/Conferences // Go blog: The Go project's official blog // https://go.dev/blog // Go project: Get help and stay informed from Go // https://go.dev/help // Get connected with google-groups // https://groups.google.com/g/golang-nuts // Get connected with github // https://github.com/golang // Get connected with twitter // https://twitter.com/golang // Get connected with reddit // https://www.reddit.com/r/golang/ // Get connected with slack // https://invite.slack.golangbridge.org/ // Get connected with stackoverflow // https://stackoverflow.com/collectives/go ``` -------------------------------- ### MIT License Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1.0/example/tmx2img The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology in the US. It is short, simple, and contains no copyleft provisions. The license is compatible with the GPL. ```text MIT License Copyright (c) 2017 Lauris Bukšis-Haberkorns Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### tmx2img Command Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.8.0/example/tmx2img The tmx2img command is part of the go-tiled library's example directory. It demonstrates how to use the library to convert Tiled map files (.tmx) into image formats. This tool is useful for game development workflows where map data needs to be visualized or exported as images. ```go package main import ( "flag" "fmt" "log" "os" "github.com/lafriks/go-tiled" "github.com/lafriks/go-tiled/render" ) func main() { inputFile := flag.String("input", "", "Path to the TMX file.") outputFile := flag.String("output", "", "Path to the output image file (e.g., output.png).") flag.Parse() if *inputFile == "" || *outputFile == "" { fmt.Println("Usage: tmx2img -input -output ") flag.PrintDefaults() os.Exit(1) } // Load the Tiled map mapData, err := tiled.LoadTMX(*inputFile) if err != nil { log.Fatalf("Error loading TMX file: %v", err) } // Render the map to an image img, err := render.Render(mapData) if err != nil { log.Fatalf("Error rendering map: %v", err) } // Save the image to a file err = render.Save(img, *outputFile) if err != nil { log.Fatalf("Error saving image: %v", err) } fmt.Printf("Successfully converted %s to %s\n", *inputFile, *outputFile) } ``` -------------------------------- ### UnmarshalXML - Map - Go Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Decodes a single XML element for the Map type, starting with the provided start element. This is used for parsing TMX map files. ```go func (m *Map) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error ``` -------------------------------- ### Go Package Documentation Navigation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.2.0/example This snippet outlines the navigation structure for Go package documentation, including sections for Why Go, Learn, Docs, and Community. It highlights key resources like Effective Go, standard library documentation, and community channels. ```go package example // This file is part of the go-tiled package. // It serves as an example and documentation entry point. // See https://go.dev/ for more information about the Go programming language. // Navigation structure: // - Why Go: Case Studies, Use Cases, Security // - Learn: Effective Go, Go User Manual, Standard library, Release Notes // - Community: Recorded Talks, Meetups, Conferences, Go blog, Go project, Get connected ``` -------------------------------- ### UnmarshalXML - Object - Go Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Decodes a single XML element for the Object type, starting with the provided start element. This is used for parsing object data within TMX map files. ```go func (o *Object) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error ``` -------------------------------- ### Go Package Documentation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.9 This section provides links to various Go documentation resources, including effective Go practices, the Go user manual, standard library references, and release notes. It also points to community resources like talks, meetups, blogs, and support channels. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### Go Project Structure and Resources Source: https://pkg.go.dev/github.com/lafriks/go-tiled/cmd%40v0.13 This section outlines the project structure, specifically the 'cmd' directory, and provides links to essential Go language resources such as effective Go practices, the user manual, standard library documentation, and release notes. It also includes community links for further engagement. ```go Project: /context7/pkg_go_dev-github.com-lafriks-go-tiled Directory: cmd/ Resources: - Why Go - Learn Go - Go Docs (Effective Go, User Manual, Standard Library, Release Notes) - Go Community (Talks, Meetups, Conferences, Blog, Project Help, Social Media Links) ``` -------------------------------- ### LayerTile Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10 Provides methods for LayerTile, such as getting the tile's rectangle. ```go func (t *LayerTile) GetTileRect() image.Rectangle ``` -------------------------------- ### Layer Processing Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Methods for decoding and processing layer data, including getting tile positions and checking if a layer is empty. ```go func (l *Layer) DecodeLayer(m *Map) error func (l *Layer) GetTilePosition(tileID int) (int, int) func (l *Layer) IsEmpty() bool func (l *Layer) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error ``` -------------------------------- ### Go Package Documentation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.12 This section provides links to various Go documentation resources, including the Go User Manual, standard library documentation, and release notes. It also highlights community resources like talks, meetups, and blogs. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### Map Utility Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Methods for interacting with loaded Tiled map data, including getting file paths and converting tile GIDs. ```go func (m *Map) GetFileFullPath(fileName string) string func (m *Map) TileGIDToTile(gid uint32) (*LayerTile, error) ``` -------------------------------- ### Properties Get Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Methods for retrieving property values of different types (string, int, float, bool, color) from Tiled properties. ```go package tiled // Get retrieves a property by name. func (p *Properties) Get(name string) (string, bool) { // Implementation details... return "", false } // GetBool retrieves a boolean property by name. func (p *Properties) GetBool(name string) (bool, bool) { // Implementation details... return false, false } // GetColor retrieves a color property by name. func (p *Properties) GetColor(name string) (string, bool) { // Implementation details... return "", false } // GetFloat retrieves a float property by name. func (p *Properties) GetFloat(name string) (float64, bool) { // Implementation details... return 0.0, false } // GetInt retrieves an integer property by name. func (p *Properties) GetInt(name string) (int, bool) { // Implementation details... return 0, false } // GetString retrieves a string property by name. func (p *Properties) GetString(name string) (string, bool) { // Implementation details... return "", false } ``` -------------------------------- ### Go Programming Language Resources Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.13.0/cmd This section provides links to essential resources for learning and using the Go programming language. It covers effective coding techniques, comprehensive user manuals, standard library documentation, and release notes for staying updated with Go's evolution. ```go // Effective Go: Tips for writing clear, performant, and idiomatic Go code // https://go.dev/doc/effective_go // Go User Manual: A complete introduction to building software with Go // https://go.dev/doc/ // Standard library: Reference documentation for Go's standard library // https://pkg.go.dev/std // Release Notes: Learn what's new in each Go release // https://go.dev/doc/devel/release ``` -------------------------------- ### Tileset Base Directory Management Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.8 Provides methods to get and set the base directory for a tileset, which is crucial for resolving relative paths to tileset assets. ```go type Tileset func (ts *Tileset) BaseDir() string func (ts *Tileset) SetBaseDir(baseDir string) ``` -------------------------------- ### Tileset Base Directory Management Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.14 Provides methods to get and set the base directory for a tileset, which is crucial for resolving relative paths to tileset assets. ```go type Tileset func (ts *Tileset) BaseDir() string func (ts *Tileset) SetBaseDir(baseDir string) ``` -------------------------------- ### Basic Usage of go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Demonstrates how to load a Tiled map file (.tmx) and render it to an image. It covers parsing the map, initializing a renderer, rendering a specific layer, and accessing the rendered image. Error handling for parsing and rendering is included. ```go package main import ( "fmt" "os" "github.com/lafriks/go-tiled" "github.com/lafriks/go-tiled/render" ) const mapPath = "maps/map.tmx" // Path to your Tiled Map. func main() { // Parse .tmx file. gameMap, err := tiled.LoadFile(mapPath) if err != nil { fmt.Printf("error parsing map: %s", err.Error()) os.Exit(2) } fmt.Println(gameMap) // You can also render the map to an in-memory image for direct // use with the default Renderer, or by making your own. renderer, err := render.NewRenderer(gameMap) if err != nil { fmt.Printf("map unsupported for rendering: %s", err.Error()) os.Exit(2) } // Render just layer 0 to the Renderer. err = renderer.RenderLayer(0) if err != nil { fmt.Printf("layer unsupported for rendering: %s", err.Error()) os.Exit(2) } // Get a reference to the Renderer's output, an image.NRGBA struct. img := renderer.Result // Clear the render result after copying the output if separation of // layers is desired. renderer.Clear() // And so on. You can also export the image to a file by using the // Renderer's Save functions. } ``` -------------------------------- ### Tileset Base Directory Management Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10 Provides methods to get and set the base directory for a tileset, which is crucial for resolving relative paths to tileset assets. ```go type Tileset func (ts *Tileset) BaseDir() string func (ts *Tileset) SetBaseDir(baseDir string) ``` -------------------------------- ### LayerTile Type Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Methods for the LayerTile type, providing functionality to get the tile's rectangle and check if it's nil. Essential for tile-based operations. ```go package tiled // GetTileRect returns the rectangular bounds of the tile. func (t *LayerTile) GetTileRect() (x, y, w, h int) { // Implementation details... return 0, 0, 0, 0 } // IsNil checks if the LayerTile is nil. func (t *LayerTile) IsNil() bool { // Implementation details... return false } ``` -------------------------------- ### Go Package Documentation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10 This section provides an overview of the go-tiled package, its purpose, and links to relevant resources such as the Go documentation, license information, and import details. It serves as an entry point for developers looking to use the package. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### Go Tiled Render Package Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11.0/render This section provides an overview of the render package for the go-tiled library. It includes links to the Go project, documentation, and community resources. ```go package render // This package provides rendering capabilities for Tiled maps. // For more information, see the official Go documentation: // https://pkg.go.dev/github.com/lafriks/go-tiled@v0.11.0/render ``` -------------------------------- ### Tileset Base Directory Management Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11 Provides methods to get and set the base directory for a tileset, which is crucial for resolving relative paths to tileset assets. ```go type Tileset func (ts *Tileset) BaseDir() string func (ts *Tileset) SetBaseDir(baseDir string) ``` -------------------------------- ### Tileset Base Directory Management Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1 Provides methods to get and set the base directory for a tileset, which is crucial for resolving relative paths to tileset assets. ```go type Tileset func (ts *Tileset) BaseDir() string func (ts *Tileset) SetBaseDir(baseDir string) ``` -------------------------------- ### Go Package Navigation Source: https://pkg.go.dev/github.com/lafriks/go-tiled/cmd%40v0.10 Provides navigation links for the go-tiled package on pkg.go.dev, including versions, licenses, and related Go resources. ```go package cmd // This package provides command-line utilities for the go-tiled library. // It includes functionality for parsing and manipulating Tiled map files. import ( "fmt" "os" "path/filepath" "github.com/lafriks/go-tiled" ) func main() { // Example usage: Load a Tiled map file filePath := "path/to/your/map.tmx" absPath, err := filepath.Abs(filePath) if err != nil { fmt.Fprintf(os.Stderr, "Error getting absolute path: %v\n", err) os.Exit(1) } file, err := os.Open(absPath) if err != nil { fmt.Fprintf(os.Stderr, "Error opening map file: %v\n", err) os.Exit(1) } defer file.Close() mapData, err := go_tiled.ParseTMX(file) if err != nil { fmt.Fprintf(os.Stderr, "Error parsing TMX file: %v\n", err) os.Exit(1) } fmt.Printf("Successfully loaded map: %s\n", mapData.Name) // Further processing of mapData can be done here } ``` -------------------------------- ### RendererEngine Interface Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1.0/render RendererEngine defines the interface for custom rendering engines. It includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC type RendererEngine interface { GetFinalImageSize() image.Rectangle GetTilePosition(x, y int) image.Rectangle Init(m *tiled.Map) RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image } ``` -------------------------------- ### OrthogonalRendererEngine for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1.0/render Defines the OrthogonalRendererEngine for rendering orthogonal Tiled maps. Includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC OrthogonalRendererEngine: // Init initializes the renderer engine with a Tiled map. Init(m *tiled.Map) // GetTilePosition calculates the image rectangle for a given tile coordinate. GetTilePosition(x, y int) image.Rectangle // GetFinalImageSize returns the dimensions of the final rendered image. GetFinalImageSize() image.Rectangle // RotateTileImage rotates the image of a tile based on its properties. RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image ``` -------------------------------- ### Map Type Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Methods for the Map type, including loading maps from files and readers, and getting the full path of included files. These are core functions for map management. ```go package tiled import "io/fs" // LoadFile loads a Tiled map from a file. func LoadFile(fileName string, options ...LoaderOption) (*Map, error) { // Implementation details... return nil, nil } // LoadReader loads a Tiled map from an io.Reader. func LoadReader(baseDir string, r io.Reader, options ...LoaderOption) (*Map, error) { // Implementation details... return nil, nil } // GetFileFullPath returns the full path of an included file. func (m *Map) GetFileFullPath(fileName string) string { // Implementation details... return "" } ``` -------------------------------- ### RendererEngine Interface Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.13.0/render RendererEngine defines the interface for custom rendering engines. It includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC type RendererEngine interface { GetFinalImageSize() image.Rectangle GetTilePosition(x, y int) image.Rectangle Init(m *tiled.Map) RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image } ``` -------------------------------- ### OrthogonalRendererEngine for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.13.0/render Defines the OrthogonalRendererEngine for rendering orthogonal Tiled maps. Includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC OrthogonalRendererEngine: // Init initializes the renderer engine with a Tiled map. Init(m *tiled.Map) // GetTilePosition calculates the image rectangle for a given tile coordinate. GetTilePosition(x, y int) image.Rectangle // GetFinalImageSize returns the dimensions of the final rendered image. GetFinalImageSize() image.Rectangle // RotateTileImage rotates the image of a tile based on its properties. RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image ``` -------------------------------- ### Renderer Initialization for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10.0/render Functions for creating and initializing a Renderer for Tiled maps. Supports initialization with a file system for external assets. ```APIDOC NewRenderer(m *tiled.Map) (*Renderer, error) // Creates a new Renderer for the given Tiled map. // Parameters: // m: The Tiled map to render. // Returns: // A pointer to the Renderer and an error if initialization fails. NewRendererWithFileSystem(m *tiled.Map, fs fs.FS) (*Renderer, error) // Creates a new Renderer for the given Tiled map, using a provided file system. // Parameters: // m: The Tiled map to render. // fs: The file system to use for loading external assets. // Returns: // A pointer to the Renderer and an error if initialization fails. ``` -------------------------------- ### OrthogonalRendererEngine for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11.0/render Defines the OrthogonalRendererEngine for rendering orthogonal Tiled maps. Includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC OrthogonalRendererEngine: // Init initializes the renderer engine with a Tiled map. Init(m *tiled.Map) // GetTilePosition calculates the image rectangle for a given tile coordinate. GetTilePosition(x, y int) image.Rectangle // GetFinalImageSize returns the dimensions of the final rendered image. GetFinalImageSize() image.Rectangle // RotateTileImage rotates the image of a tile based on its properties. RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image ``` -------------------------------- ### Renderer Initialization for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11.0/render Functions for creating and initializing a Renderer for Tiled maps. Supports initialization with a file system for external assets. ```APIDOC NewRenderer(m *tiled.Map) (*Renderer, error) // Creates a new Renderer for the given Tiled map. // Parameters: // m: The Tiled map to render. // Returns: // A pointer to the Renderer and an error if initialization fails. NewRendererWithFileSystem(m *tiled.Map, fs fs.FS) (*Renderer, error) // Creates a new Renderer for the given Tiled map, using a provided file system. // Parameters: // m: The Tiled map to render. // fs: The file system to use for loading external assets. // Returns: // A pointer to the Renderer and an error if initialization fails. ``` -------------------------------- ### RendererEngine Interface Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11.0/render RendererEngine defines the interface for custom rendering engines. It includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC type RendererEngine interface { GetFinalImageSize() image.Rectangle GetTilePosition(x, y int) image.Rectangle Init(m *tiled.Map) RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image } ``` -------------------------------- ### Renderer Initialization for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.13.0/render Functions for creating and initializing a Renderer for Tiled maps. Supports initialization with a file system for external assets. ```APIDOC NewRenderer(m *tiled.Map) (*Renderer, error) // Creates a new Renderer for the given Tiled map. // Parameters: // m: The Tiled map to render. // Returns: // A pointer to the Renderer and an error if initialization fails. NewRendererWithFileSystem(m *tiled.Map, fs fs.FS) (*Renderer, error) // Creates a new Renderer for the given Tiled map, using a provided file system. // Parameters: // m: The Tiled map to render. // fs: The file system to use for loading external assets. // Returns: // A pointer to the Renderer and an error if initialization fails. ``` -------------------------------- ### RendererEngine Interface Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10.0/render RendererEngine defines the interface for custom rendering engines. It includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC type RendererEngine interface { GetFinalImageSize() image.Rectangle GetTilePosition(x, y int) image.Rectangle Init(m *tiled.Map) RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image } ``` -------------------------------- ### Go Tiled Render Package Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.13.0/render Provides an overview of the 'render' package within the go-tiled library. It details package structure, versioning, licensing, and import relationships, crucial for understanding dependencies and usage. ```go package render // This package provides functionality for rendering Tiled map data. // It handles the conversion of Tiled map structures into visual representations. ``` -------------------------------- ### OrthogonalRendererEngine for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10.0/render Defines the OrthogonalRendererEngine for rendering orthogonal Tiled maps. Includes methods for initializing the engine, getting tile positions, and rotating tile images. ```APIDOC OrthogonalRendererEngine: // Init initializes the renderer engine with a Tiled map. Init(m *tiled.Map) // GetTilePosition calculates the image rectangle for a given tile coordinate. GetTilePosition(x, y int) image.Rectangle // GetFinalImageSize returns the dimensions of the final rendered image. GetFinalImageSize() image.Rectangle // RotateTileImage rotates the image of a tile based on its properties. RotateTileImage(tile *tiled.LayerTile, img image.Image) image.Image ``` -------------------------------- ### Go Tiled cmd Package Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11.0/cmd This section provides an overview of the cmd package for the go-tiled library. It details the purpose and structure of the command-line interface tools provided by the package. ```go package cmd // The cmd package provides command-line interface tools for working with Tiled map files. // It includes functionalities for parsing, manipulating, and exporting map data. // // Example Usage: // go run main.go [arguments] ``` -------------------------------- ### Go Tiled Command Directory Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/cmd%40v0.9 This section provides an overview of the cmd directory within the go-tiled package. It serves as the entry point for understanding the command-line utilities provided by the library. ```go package cmd // This directory contains the command-line interface tools for the go-tiled package. // It provides executables for interacting with Tiled map files. ``` -------------------------------- ### UnmarshalXML for Text Object Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index The UnmarshalXML method is used to decode a single XML element for Text objects. It takes an XML decoder and a start element as input and returns an error if the decoding fails. ```go func (t *Text) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { // Implementation details for unmarshalling XML into Text object return nil } ``` -------------------------------- ### Property Handling Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1 Includes methods for unmarshalling XML properties and retrieving color properties from a set of properties. ```go type Property func (p *Property) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error type Properties func (p Properties) GetColor(name string) color.Color ``` -------------------------------- ### Properties Get Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Provides methods to retrieve property values by name from a Properties collection. Supports retrieving values as strings, integers, floats, booleans, and colors. GetColor specifically parses color values. ```go func (p Properties) Get(name string) []string func (p Properties) GetBool(name string) bool func (p Properties) GetColor(name string) color.Color func (p Properties) GetFloat(name string) float64 func (p Properties) GetInt(name string) int func (p Properties) GetString(name string) string ``` -------------------------------- ### Tileset Loading and Management Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Functions and methods for loading tilesets from files and readers, and managing tileset properties like base directory and tile rectangles. ```go package tiled import "io" // LoadTilesetFile loads a tileset from a file path. func LoadTilesetFile(fileName string, options *LoadOptions) (*Tileset, error) { // Implementation details... return nil, nil } // LoadTilesetReader loads a tileset from an io.Reader. func LoadTilesetReader(baseDir string, r io.Reader, options *LoadOptions) (*Tileset, error) { // Implementation details... return nil, nil } // BaseDir returns the base directory of the tileset. func (ts *Tileset) BaseDir() string { // Implementation details... return "" } // GetFileFullPath returns the full path to a file within the tileset's directory. func (ts *Tileset) GetFileFullPath(fileName string) string { // Implementation details... return "" } // GetTileRect returns the rectangle coordinates for a given tile ID. func (ts *Tileset) GetTileRect(tileID int) (Rect, bool) { // Implementation details... return Rect{}, false } // GetTilesetTile retrieves a specific tileset tile by its ID. func (ts *Tileset) GetTilesetTile(tileID int) (*TilesetTile, bool) { // Implementation details... return nil, false } // SetBaseDir sets the base directory for the tileset. func (ts *Tileset) SetBaseDir(baseDir string) { // Implementation details... } ``` -------------------------------- ### Layer Decoding and Unmarshaling Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Provides methods for decoding layer data from a Map and unmarshaling XML data for a layer. DecodeLayer takes a Map and returns an error, while UnmarshalXML handles XML decoding with a provided decoder and start element. ```go func (l *Layer) DecodeLayer(m *Map) error { // ... implementation details ... } func (l *Layer) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { // ... implementation details ... } ``` -------------------------------- ### Property Handling Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11 Includes methods for unmarshalling XML properties and retrieving color properties from a set of properties. ```go type Property func (p *Property) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error type Properties func (p Properties) GetColor(name string) color.Color ``` -------------------------------- ### Go Tiled Package Overview Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.7 This section provides an overview of the go-tiled package, its purpose, and links to relevant Go documentation resources. It highlights the package's role in working with Tiled map files. ```go package module // Main Versions // Licenses // Imports // Imported By ``` -------------------------------- ### Go Module Information Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Details about the go-tiled Go module, including version, publication date, license, and dependencies. It also touches upon Go module best practices like versioning and license compliance. ```go package module // Version: v0.14.0 // Published: Jul 28, 2025 // License: MIT // Imports: 15 // Imported by: 58 // The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go. // Modules with tagged versions give importers more predictable builds. // When a project reaches major version v1 it is considered stable. // Learn more about best practices: https://pkg.go.dev/about#best-practices ``` -------------------------------- ### LayerTile Structure and Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Defines the LayerTile structure, which holds information about a tile within a layer, including its ID, tileset, flip states, and nil status. It also provides methods to get the tile's rectangle and check if it's nil. ```go type LayerTile struct { // Tile ID ID uint32 // Tile tileset Tileset *Tileset // Horizontal tile image flip HorizontalFlip bool // Vertical tile image flip VerticalFlip bool // Diagonal tile image flip DiagonalFlip bool // Tile is nil Nil bool } func (t *LayerTile) GetTileRect() image.Rectangle { // ... implementation details ... } func (t *LayerTile) IsNil() bool { // ... implementation details ... } ``` -------------------------------- ### Property Handling Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.8 Includes methods for unmarshalling XML properties and retrieving color properties from a set of properties. ```go type Property func (p *Property) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error type Properties func (p Properties) GetColor(name string) color.Color ``` -------------------------------- ### Property Handling Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.10 Includes methods for unmarshalling XML properties and retrieving color properties from a set of properties. ```go type Property func (p *Property) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error type Properties func (p Properties) GetColor(name string) color.Color ``` -------------------------------- ### Property Handling Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.14 Includes methods for unmarshalling XML properties and retrieving color properties from a set of properties. ```go type Property func (p *Property) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error type Properties func (p Properties) GetColor(name string) color.Color ``` -------------------------------- ### Renderer Initialization for go-tiled Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1.0/render Functions for creating and initializing a Renderer for Tiled maps. Supports initialization with a file system for external assets. ```APIDOC NewRenderer(m *tiled.Map) (*Renderer, error) // Creates a new Renderer for the given Tiled map. // Parameters: // m: The Tiled map to render. // Returns: // A pointer to the Renderer and an error if initialization fails. NewRendererWithFileSystem(m *tiled.Map, fs fs.FS) (*Renderer, error) // Creates a new Renderer for the given Tiled map, using a provided file system. // Parameters: // m: The Tiled map to render. // fs: The file system to use for loading external assets. // Returns: // A pointer to the Renderer and an error if initialization fails. ``` -------------------------------- ### Properties Get Methods Source: https://pkg.go.dev/github.com/lafriks/go-tiled/index Provides methods to retrieve property values from a Properties object by name. Supports various data types including strings, integers, floats, booleans, colors, and string slices. These methods are essential for accessing custom properties defined in Tiled maps. ```APIDOC Properties.Get(name string) []string Retrieves a string slice property by name. Properties.GetBool(name string) bool Retrieves a boolean property by name. Properties.GetColor(name string) color.Color Retrieves a color property by name, returning a color.Color type. Properties.GetFloat(name string) float64 Retrieves a float64 property by name. Properties.GetInt(name string) int Retrieves an integer property by name. Properties.GetString(name string) string Retrieves a string property by name. ``` -------------------------------- ### Loader Options Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.1 Defines options that can be passed to map loading functions to customize behavior. The WithFileSystem option allows specifying a custom file system. ```go type LoaderOption func(*loader) func WithFileSystem(fileSystem fs.FS) LoaderOption ``` -------------------------------- ### Loader Options Source: https://pkg.go.dev/github.com/lafriks/go-tiled/%40v0.11 Defines options that can be passed to map loading functions to customize behavior. The WithFileSystem option allows specifying a custom file system. ```go type LoaderOption func(*loader) func WithFileSystem(fileSystem fs.FS) LoaderOption ```