Help us shape the future of Go! Take the 2026 Go Developer Survey

render

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

DEPRECATED: This package is deprecated. Use parable-bloom/tools/level-builder instead. Future versions will port this functionality to the new CLI.

Index

Constants

This section is empty.

Variables

View Source
var LevelRenderCmd = &cobra.Command{
	Use:   "level-render",
	Short: "Render a level to the terminal (ASCII/Unicode)",
	Long: `Render a level to the terminal for quick visual inspection.

You can supply a file path with --file (-f) or a level id with --id (-i) (looks in assets/levels).
`,
	Run: func(cmd *cobra.Command, _args []string) {
		isVerbose := utils.IsVerbose(cmd)
		log.Start("Rendering level")

		file, _ := cmd.Flags().GetString("file")
		id, _ := cmd.Flags().GetInt("id")
		style, _ := cmd.Flags().GetString("style")
		showCoords, _ := cmd.Flags().GetBool("coords")

		var level *common.Level
		var err error
		if file != "" {
			level, err = common.ReadLevel(file)
			if err != nil {
				log.Error("Failed to read level file: %v", err)
				return
			}
		} else if id != 0 {
			path := common.GetLevelFilePath(id, "assets/levels")
			if !common.FileExists(path) {
				log.Error("Level file not found: %s", path)
				return
			}
			level, err = common.ReadLevel(path)
			if err != nil {
				log.Error("Failed to read level file: %v", err)
				return
			}
		} else {
			log.Error("Please provide either --file or --id to render a level")
			return
		}

		if style == "" {
			style = "unicode"
		}

		RenderLevelToWriter(cmd.OutOrStdout(), level, style, showCoords)
		log.Verbose(isVerbose, "Render complete")
	},
}

LevelRenderCmd prints a visual representation of a level to the terminal.

Functions

func RenderLevelToWriter

func RenderLevelToWriter(w io.Writer, level *common.Level, style string, showCoords bool)

RenderLevelToWriter prints a visual representation of a level to the given writer. style can be "ascii" or "unicode".

Types

This section is empty.

Jump to

Keyboard shortcuts

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