goansi

package module
v0.0.0-...-e95170f Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2017 License: BSD-3-Clause Imports: 13 Imported by: 3

README

Description

go-ansi converts ANSi art files to PNG files. go-ansi is a Go port of ansilove/C that aims to have as few external dependencies as possible. It provides both a command-line application and a package interface to allow you to integrate it with your own applications.

go-ansi supports all of the options from ansilove/C with the addition of 24bit ANSi support.

Installation

After cloning this repo or downloading the code, you'll need to ensure that any required dependencies are installed.

First, you will need a version of the Go programming language installed. You can of course download ActiveGo for your preferred platform.

This package uses github.com/nfnt/resize. You can either manually place this within the vendor folder, or use a dependency management package.

While it is still in development, we recommend using the dep tool. You can get it from github.com/golang/dep or via the Go toolchain:

   $ go get -u github.com/golang/dep/...

After installing dep you can use it to fetch the dependencies automatically:

   $ dep init
   $ dep ensure -update

Features

Rendering of all known ANSi / ASCII art file types:

  • ANSi (.ANS)
  • Binary (.BIN)
  • Artworx (.ADF)
  • iCE Draw (.IDF)
  • Xbin (.XB) details
  • PCBoard (.PCB)
  • Tundra (.TND) details
  • ASCII (.ASC)
  • Release info (.NFO)
  • Description in zipfile (.DIZ)

Files with custom suffix default to the ANSi renderer (e.g. ICE or CIA).

go-ansi is capabable of processing:

  • SAUCE records
  • DOS and Amiga fonts (embedded binary dump)
  • iCE colors

Even more:

  • Output files are highly optimized 4-bit PNGs.
  • Optionally generates additional (and proper) Retina @2x PNG.
  • You can use custom options for adjusting output results.
  • Built-in support for rendering Amiga ASCII.
  • Support for 24-bit ANSi

Documentation

Synopsis

   go-ansi [options] file
   go-ansi -e | -h | -v

Options

   -b bits     set to 9 to render 9th column of block characters (default: 8)
   -c columns  adjust number of columns for BIN files (default: 160)
   -e          print a list of examples
   -f font     select font (default: 80x25)
   -h          show help
   -i          enable iCE colors
   -m mode     set rendering mode for ANS files:
                 ced            black on gray, with 78 columns
                 transparent    render with transparent background
                 workbench      use Amiga Workbench palette
   -o file     specify output filename/path
   -r          creates additional Retina @2x output file
   -s          show SAUCE record without generating output
   -v          show version information

There are certain cases where you need to set options for proper rendering. However, this is occasionally. Results turn out well with the built-in defaults. You may launch go-ansi with the option -e to get a list of basic examples. Note that columns is restricted to BIN and TND files, it won't affect other file types.

Fonts

go-ansi inherits all the embedded fonts from ansilove/C as binary data, so the most popular typefaces for rendering ANSi / ASCII art are available at your fingertips.

PC fonts can be (all case-sensitive):

  • 80x25 (code page 437)
  • 80x50 (code page 437, 80x50 mode)
  • baltic (code page 775)
  • cyrillic (code page 855)
  • french-canadian (code page 863)
  • greek (code page 737)
  • greek-869 (code page 869)
  • hebrew (code page 862)
  • icelandic (Code page 861)
  • latin1 (code page 850)
  • latin2 (code page 852)
  • nordic (code page 865)
  • portuguese (Code page 860)
  • russian (code page 866)
  • terminus (modern font, code page 437)
  • turkish (code page 857)

AMIGA fonts can be (all case-sensitive):

  • amiga (alias to Topaz)
  • microknight (Original MicroKnight version)
  • microknight+ (Modified MicroKnight version)
  • mosoul (Original mO'sOul font)
  • pot-noodle (Original P0T-NOoDLE font)
  • topaz (Original Topaz Kickstart 2.x version)
  • topaz+ (Modified Topaz Kickstart 2.x+ version)
  • topaz500 (Original Topaz Kickstart 1.x version)
  • topaz500+ (Modified Topaz Kickstart 1.x version)

Bits

bits can be (all case-sensitive):

  • 8 (8-bit)
  • 9 (9-bit)

Setting the bits to 9 will render the 9th column of block characters, so the output will look like it is displayed in real textmode.

Rendering Mode

mode can be (all case-sensitive):

  • ced
  • transparent
  • workbench

Setting the mode to ced will cause the input file to be rendered in black on gray, and limit the output to 78 columns (only available for ANS files). Used together with an Amiga font, the output will look like it is displayed on Amiga.

Setting the mode to workbench will cause the input file to be rendered using Amiga Workbench colors (only available for ANS files).

Settings the mode to transparent will produce output files with transparent background (only available for ANS files).

iCE Colors

iCE colors are disabled by default, and can be enabled by specifying the -i option.

When an ANSi source was created using iCE colors, it was done with a special mode where the blinking was disabled, and you had 16 background colors available. Basically, you had the same choice for background colors as for foreground colors, that's iCE colors.

Columns

columns is only relevant for .BIN files, and even for those files is optional. In most cases conversion will work fine if you don't set this flag, the default value is 160 then. So please pass columns only to BIN files and only if you exactly know what you're doing.

SAUCE records

You can use go-ansi as SAUCE reader without generating any output, just use option -s for this purpose.

License

go-ansi is released under the BSD 3-Clause license. See LICENSE file for details.

Author

go-ansi is developed by Pete Garcin.

Based on ansilove/C. ansilove is developed by Stefan Vogt, Brian Cassidy, Frederic Cambus.

Resources

Project Homepage : https://github.com/ActiveState/go-ansi

Documentation

Overview

package goansi provides library-level access to ANSi file formats and SAUCE records

Index

Constants

View Source
const SauceID = "SAUCE"

SauceID is the SAUCE record identifier tagged onto the file data

Variables

This section is empty.

Functions

func Parse

func Parse(inputFileBuffer []byte, inputFileSize int64, fontName string, bits int, columns int, mode string, icecolors bool, fext string, scaleFactor float32) image.Image

Parse takes a buffer of ANSi data and returns an Image.image

func WritePng

func WritePng(fileName string, img image.Image, scaleFactor float32)

WritePng takes an image and filename and encodes to png

Types

type Sauce

type Sauce struct {
	Sauceinf     SauceInfo
	CommentLines []string
}

Sauce - container structure for sauceInfo and variable length comments This feels like a bit of a hack

func GetSauce

func GetSauce(fileName string) Sauce

GetSauce returns a sauce record for a given file if it exists

type SauceInfo

type SauceInfo struct {
	ID       [5]byte
	Version  [2]byte
	Title    [35]byte
	Author   [20]byte
	Group    [20]byte
	Date     [8]byte
	FileSize int32
	DataType byte
	FileType byte
	Tinfo1   uint16
	Tinfo2   uint16
	Tinfo3   uint16
	Tinfo4   uint16
	Comments byte
	Flags    byte
	Filler   [22]byte
}

SauceInfo contains the bulk of the SAUCE record

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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