Documentation ¶
Index ¶
- Variables
- func GetOutputFileName(outputPath string, outName string) (string, error)
- func HSLtoRGB(h, s, l float64) (float64, float64, float64)
- func InitFS(outputPath string)
- func InitSettings(cliArgs *CLIArgs) flexiconfig.Settings
- func RGBtoHSL(r, g, b float64) (float64, float64, float64)
- type CLIArgs
- type HSLColor
- type Painting
- type Palette
- type Renderer
- func (this *Renderer) Circle(filled bool, x, y, radius float64)
- func (this *Renderer) GetSurface() *cairo.Surface
- func (this *Renderer) Line(connected bool, points []Vector2d)
- func (this *Renderer) LineWidth(lineWidth float64)
- func (this *Renderer) Polygon(points []Vector2d)
- func (this *Renderer) SavePNG(outPath string)
- func (this *Renderer) SetBlendMode(operator cairo.Operator)
- func (this *Renderer) SetColor(color HSLColor, alpha float64)
- type Simulator
- type Vector2d
- func (this Vector2d) Add(other Vector2d) Vector2d
- func (this Vector2d) AddScalar(scalar float64) Vector2d
- func (this Vector2d) Direction() float64
- func (this Vector2d) Distance(other Vector2d) float64
- func (this Vector2d) Div(other Vector2d) Vector2d
- func (this Vector2d) DivScalar(scalar float64) Vector2d
- func (this Vector2d) Equals(other Vector2d) bool
- func (this Vector2d) Length() float64
- func (this Vector2d) LengthSq() float64
- func (this Vector2d) Mult(other Vector2d) Vector2d
- func (this Vector2d) MultScalar(scalar float64) Vector2d
- func (this Vector2d) Normalize() Vector2d
- func (this Vector2d) PolarCoordinates() (float64, float64)
- func (this Vector2d) Rotate(theta float64) Vector2d
- func (this Vector2d) String() string
- func (this Vector2d) Sub(other Vector2d) Vector2d
- func (this Vector2d) SubScalar(scalar float64) Vector2d
- type World
Constants ¶
This section is empty.
Variables ¶
var Palettes = map[string]Palette{
"pleasant": {
{0.500, 0.33, 0.70},
{0.436, 0.23, 0.61},
{0.286, 0.28, 0.66},
{0.119, 0.70, 0.83},
{0.072, 0.33, 0.70},
},
"vangogh_cafeterrace": {
{0.1361, 0.7200, 0.5700},
{0.6000, 0.4400, 0.3800},
{0.3306, 0.1900, 0.2500},
{0.0889, 0.7600, 0.5700},
{0.3361, 0.1900, 0.2200},
{0.6056, 0.3900, 0.4200},
{0.1806, 0.5700, 0.8100},
},
"vangogh_roadwithcypressandstar": {
{0.0417, 0.6800, 0.4100},
{0.1611, 0.9600, 0.8200},
{0.6333, 0.6100, 0.4300},
{0.7333, 0.7300, 0.0600},
{0.7528, 0.9900, 0.0500},
{0.5833, 0.5300, 0.5600},
{0.6389, 0.6700, 0.0800},
},
"port": {
{0.0389, 0.8700, 0.5200},
{0.5944, 1.0000, 0.5000},
{0.5694, 0.9000, 0.2700},
{0.4889, 0.3200, 0.2500},
{0.0472, 0.1300, 0.4100},
{0.0778, 0.4700, 0.6500},
},
"vangogh_potatoeaters": {
{0.2361, 0.3100, 0.1400},
{0.1222, 0.6900, 0.2900},
{0.1139, 0.7000, 0.4300},
{0.2528, 0.3700, 0.0700},
{0.1500, 0.2800, 0.4700},
{0.1361, 0.4500, 0.1400},
{0.2861, 0.2200, 0.0800},
},
"grayscale": {
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.1},
{0.0, 0.0, 0.2},
{0.0, 0.0, 0.3},
{0.0, 0.0, 0.4},
{0.0, 0.0, 0.5},
{0.0, 0.0, 0.6},
{0.0, 0.0, 0.7},
},
"desert1": {
{0.6111, 0.2700, 0.3000},
{0.0833, 0.1600, 0.4900},
{0.0778, 0.5000, 0.7000},
{0.0806, 0.5300, 0.8700},
{0.0861, 0.3800, 0.7600},
{0.5833, 0.5100, 0.9400},
{0.9750, 0.0400, 0.6100},
},
}
var ProgramVersionID string
ProgramVersionID is a string that can be set when building in order to identify the version ID of the program. For instance, to set it to the commit ID of your project you can run go build like this:
go build -ldflags "-X github.com/wetdesertrock/gart.ProgramVersionID=$GIT_COMMIT"
gart will store this ID in the metadata and print it to stdout
Functions ¶
func GetOutputFileName ¶
GetOutputFileName will look at a given path with a given name string and looks for the next available file name. Files are assumed to be named like this: "<outName>_<id>.png". The ID is determined by the files in the folder and will automatically be set to the max ID found + 1.
func InitFS ¶
func InitFS(outputPath string)
InitFS is given an output path and does any fs specific initializations (currently just creating the output folder).
func InitSettings ¶
func InitSettings(cliArgs *CLIArgs) flexiconfig.Settings
InitSettings loads the settings files (reading them from the args if needed) You shouldn't need to invoke this directly. It is exposed incase somone needs to initialize the program manually.
Types ¶
type CLIArgs ¶
type CLIArgs struct { ConfigPaths []string `flag:"config-path" short:"c" help:"Loads the specified config file"` OutputConfig string `flag:"config-out" short:"O" help:"Saves the resulting config at the specified path"` }
func InitCLIArgs ¶
func InitCLIArgs() *CLIArgs
InitCLIArgs parses the CLI arguments and returns them. You shouldn't need to invoke this directly. It is exposed incase somone needs to initialize the program manually.
func InitProgram ¶
func InitProgram(name string) (flexiconfig.Settings, *CLIArgs)
InitProgram does all of the mundane tasks needed to run a program. You shouldn't need to invoke this directly. It is exposed incase somone needs to initialize the program manually.
type HSLColor ¶
HSLColor is a struct used to hold and operate on HSL colors
func NewHSLColor ¶
func NewHSLColorFromRGB ¶
type Painting ¶
type Painting struct { Renderer *Renderer Settings flexiconfig.Settings }
Painting is the core struct that allows you to render and save your image
func InitProgramWithPainting ¶
InitProgramWithPainting will setup the program (parse CLI args, retrive settings), and setup a Painting to use.
func NewPainting ¶
func NewPainting(settings flexiconfig.Settings) *Painting
NewPainting creates a new painting struct using the settings object. You shouldn't need to ever use this yourself for normal use. Instead you should use InitProgramWithPainting.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is a struct that holds the cairo instance and exposes wrapper methods using cairo. This is the struct you will use to do the actual drawaing.
func NewRenderer ¶
func NewRenderer(config flexiconfig.Settings) *Renderer
NewRenderer creates a new renderer from a settings instance. You shouldn't need to use this for average use. It will be created when you create a new painting or simulator.
func (*Renderer) GetSurface ¶
func (this *Renderer) GetSurface() *cairo.Surface
GetSurface returns the underlying cairo Surface.
func (*Renderer) SetBlendMode ¶
func (this *Renderer) SetBlendMode(operator cairo.Operator)
SetBlendMode sets the blend mode for cairo.
type Simulator ¶
type Simulator struct { *Painting // contains filtered or unexported fields }
Simulator is a struct that provides an easy way of drawing things in a simulated fashion similar to game engines. It allows you to define a framerate and how long it will run for.
func InitProgramWithSimulator ¶
InitProgramWithSimulator will setup the program (parse CLI args, retrive settings), and setup a Simulator with the supplied world.
func NewSimulator ¶
func NewSimulator(world World, settings flexiconfig.Settings) *Simulator
NewSimulator creates a new simulator struct using the settings object. You shouldn't need to ever use this yourself for normal use. Instead you should use InitProgramWithSimulator.
type Vector2d ¶
Vector2d is a immutable struct for doing 2d vector operations.
func NewVector2d ¶
NewVector2d creates a new vector from the x and y components
func NewVector2dFromPolar ¶
NewVector2dFromPolar creates a new vector from a given angle and maagnitude.
func (Vector2d) LengthSq ¶
LengthSq returns the length of the vector squared. This should provide performance benefits when in tight loops by not doing math.Sqrt().
func (Vector2d) MultScalar ¶
func (Vector2d) PolarCoordinates ¶
PolarCoordinates returns the angle and magnitude of the vector.