flame

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: Zlib Imports: 9 Imported by: 0

README

xirho/encoding/flame

Package flame implements parsing the XML-based Flame format used by flam3 and Apophysis.

By default, the parser recognizes the following variations and their parameters:

  • linear (always treated as 3D)
  • linear3D
  • bipolar
  • blur
  • pre_blur
  • bubble
  • elliptic (not identical to Apophysis's elliptic)
  • curl
  • cylinder
  • disc
  • exp
  • expo
  • flatten
  • foci
  • gaussian_blur
  • post_heat
  • julia (not tested and probably wrong)
  • julian
  • lazysusan
  • log
  • mobius
  • mobiq
  • polar
  • rod (rod_blur parameter is ignored)
  • scry
  • spherical
  • spherical3D
  • pre_spherical
  • splits
  • splits3D
  • unpolar

Adding variations

The decoder ignores any xform attributes it doesn't recognize. To teach it to understand more variation types, create a Parser function and add it to the Funcs map.

Documentation

Overview

Package flame implements parsing the XML-based Flame format.

The unmarshaler ignores any unknown variation types. To allow it to load new types, add to the Funcs map.

While the goal is to produce results identical to Apophysis, it may not be possible in all cases.

Index

Constants

This section is empty.

Variables

View Source
var Funcs = map[string]Parser{
	"linear":        parseLinear,
	"linear3D":      parseLinear,
	"bipolar":       parseBipolar,
	"blur":          parseBlur,
	"pre_blur":      parsePreblur,
	"bubble":        parseBubble,
	"elliptic":      parseElliptic,
	"exp":           parseExp,
	"expo":          parseExpo,
	"curl":          parseCurl,
	"cylinder":      parseCylinder,
	"disc":          parseDisc,
	"flatten":       parseFlatten,
	"foci":          parseFoci,
	"gaussian_blur": parseGaussblur,
	"post_heat":     parsePostHeat,
	"julia":         parseJulia,
	"julian":        parseJulian,
	"lazysusan":     parseLazySusan,
	"log":           parseLog,
	"mobius":        parseMobius,
	"mobiq":         parseMobiq,
	"polar":         parsePolar,
	"rod":           parseRod,
	"scry":          parseScry,
	"spherical":     parseSpherical,
	"spherical3D":   parseSpherical3D,
	"pre_spherical": parsePrespherical,
	"splits":        parseSplits,
	"splits3D":      parseSplits3D,
	"unpolar":       parseUnpolar,
}

Funcs maps Flame xform attribute names to functions which parse attributes into function instances. Parameters of functions should not included here, e.g. julian is an entry but julian_power is not, as the parser should handle the parameters.

Functions

This section is empty.

Types

type Flame

type Flame struct {
	// Name is the name of the flame.
	Name string
	// System is the encoded function system.
	System xirho.System
	// R is the renderer for the system. Its histogram should be Reset to the
	// appropriate size before rendering.
	R *xirho.Render
	// Aspect is the aspect ratio (number of columns per row in the image, or
	// width divided by height) of the system as encoded in the flame file.
	Aspect float64
	// BG is the background color for the system. The alpha component is always
	// maximized.
	BG color.NRGBA64
	// Err holds any error that occurred while decoding this flame.
	Err error
}

Flame holds a decoded renderer and extra information about it.

func Unmarshal

func Unmarshal(d *xml.Decoder) (Flame, error)

Unmarshal decodes a renderer from Flame XML. The decoder must be positioned at a flame element, rather than at the flames element at the start of a typical file; one may use d.Token() or d.RawToken() to advance the decoder to the correct position. The returned error is the same as the Flame's Err field.

func UnmarshalAll

func UnmarshalAll(d *xml.Decoder) ([]Flame, error)

UnmarshalAll decodes all systems in an Apophysis flame file. The decoder must be positioned at a flames element. The returned error is independent of errors in the decoded flames, and it may be nil even if no flames were successfully decoded.

type Parser

type Parser func(attrs map[string]float64, pre, in, post *xi.Sum, ax xirho.Ax)

Parser is a function which parses a xirho function from XML attributes. Parsers should add the parsed function to one of pre, in, or post, and they should not modify attrs.

Jump to

Keyboard shortcuts

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