Documentation ¶
Index ¶
- Variables
- type Identicon
- func (i *Identicon) CheckConfiguration()
- func (i *Identicon) CheckHash()
- func (i *Identicon) GenerateHash()
- func (i *Identicon) GenerateMatrix()
- func (i *Identicon) New() *Identicon
- func (i *Identicon) Print()
- func (i *Identicon) ReadConfiguration(path string)
- func (i *Identicon) SaveImage(path string)
- func (i *Identicon) SaveSVG(path string)
- func (i *Identicon) UseDefaultConfiguration()
- type IdenticonConfiguration
- type IdenticonIF
- type ImageConfiguration
Constants ¶
This section is empty.
Variables ¶
var IdenticonDefaultOptions = IdenticonConfiguration{ Size: 6, Square: false, Border: false, Vertical: false, Invert: false, Symmetric: false, }
var ImageDefaultOptions = ImageConfiguration{ Size: "L", Portrait: false, FG: "6dff24", BG: "0b2100", }
Functions ¶
This section is empty.
Types ¶
type Identicon ¶
type Identicon struct { IdenticonOptions IdenticonConfiguration ImageOptions ImageConfiguration Text string Hash string // contains filtered or unexported fields }
func (*Identicon) CheckConfiguration ¶ added in v0.2.0
func (i *Identicon) CheckConfiguration()
Checks both Identicon.IdenticonOptions & Identicon.ImageOptions altogether for errors (kind of an One-Time function call).
When both Identicon.IdenticonOptions & Identicon.ImageOptions were already set by any means, then use this function directly instead of seperately calling Identicon.IdenticonOptions.CheckConfiguration() and Identicon.ImageOptions.CheckConfiguration(), to check for errors.
i.e.: Identicon.CheckConfiguration()
func (*Identicon) CheckHash ¶ added in v1.2.0
func (i *Identicon) CheckHash()
Checks the already set Identicon.Hash and sets Indenticon.Width & Identicon.Height based on Identicon.IdenticonOptions.Square (bool).
if: Identicon.IdenticonOptions.Square == TRUE, then for square (1:1) aspect ratios set Identicon.width, Identicon.height = 1, 1
else: for wide (2:1) aspect ratios set Identicon.width, Identicon.height = 2, 1
func (*Identicon) GenerateHash ¶
func (i *Identicon) GenerateHash()
Sets Identicon.Hash, Indenticon.Width & Identicon.Height based on Identicon.IdenticonOptions.Square (bool).
if: Identicon.IdenticonOptions.Square == TRUE, then generate(set) Identicon.Hash suitable for square (1:1) aspect ratios and set Identicon.width, Identicon.height = 1, 1
else: generate(set) Identicon.Hash suitable for wide (2:1) aspect ratios and set Identicon.width, Identicon.height = 2, 1
func (*Identicon) GenerateMatrix ¶
func (i *Identicon) GenerateMatrix()
Sets Identicon.Matrix based on some Identicon.IdenticonOptions. Uses IdenticonConfiguration.Vertical (bool), IdenticonConfiguration.Invert (bool) & IdenticonConfiguration.Symmetric (bool) to generate 8 different types of matrices.
Combinations: vertical-inverted-symmetric, vertical-inverted-asymmetric, vertical-original-symmetric vertical-original-asymmetric, horizontal-inverted-symmetric, horizontal-inverted-asymmetric horizontal-original-symmetric, horizontal-original-asymmetric
func (*Identicon) New ¶ added in v1.2.0
Handles all the intermediate steps for generating an identicon from Identicon configuration. It requires to have the Identicon configuration (Identicon, ImageConfiguration, IdenticonConfiguration) options to be set. Typically used for programmatically generating identicons. Chainable to allow New().SaveImage() & New().SaveSVG().
func (*Identicon) Print ¶
func (i *Identicon) Print()
Printing the Identicon.Matrix to the terminal. Identicon.IdenticonOptions.Border (bool) is used to determine whether to print the identicon with/without border.
func (*Identicon) ReadConfiguration ¶ added in v0.2.0
Read, Check & Set configurations from a JSON config file. Sets both Identicon.IdenticonOptions & Identicon.ImageOptions requires: absolute/relative path of the JSON file.
func (*Identicon) SaveImage ¶ added in v0.3.0
Creates and saves an identicon as PNG image. Requires a `path` variable to be passed, as an image saving directory or name. Size of the image identicon depends on the Identicon.ImageOptions.Size property which is minimum of either width & height of the image, divided by some value.
func (*Identicon) SaveSVG ¶ added in v0.3.0
Creates and saves an identicon as SVG. Requires a `path` variable to be passed, as a SVG saving directory or name. Size of the SVG identicon depends on the Cell Size of every block in the identicon, which is currently hardcoded to 100 units.
func (*Identicon) UseDefaultConfiguration ¶
func (i *Identicon) UseDefaultConfiguration()
Sets Identicon.IdenticonOptions & Identicon.ImageOptions using default values specified as variables - IdenticonDefaultOptions & ImageDefaultOptions for identicon & image respectively.
type IdenticonConfiguration ¶
type IdenticonConfiguration struct { Size int `json:"size"` // sets size of the identicon (range: 4-8) Square bool `json:"square"` // creates a square identicon Border bool `json:"border"` // adds a border to the identicon Vertical bool `json:"vertical"` // creates identicon in portrait dimension (not visible on using --square flag) Invert bool `json:"invert"` // inverts the cell filling of identicon Symmetric bool `json:"symmetric"` // creates symmetric identicon }
func (*IdenticonConfiguration) CheckConfiguration ¶
func (o *IdenticonConfiguration) CheckConfiguration()
Checks Identicon.IdenticonOptions for errors
type IdenticonIF ¶
type IdenticonIF interface { // Sets Identicon.IdenticonOptions & Identicon.ImageOptions // using default values specified as variables - // IdenticonDefaultOptions & ImageDefaultOptions for // identicon & image respectively. UseDefaultConfiguration() // Read, Check & Set configurations from a JSON config file. // Sets both Identicon.IdenticonOptions & Identicon.ImageOptions. // (requires: absolute/relative path of the JSON file) ReadConfiguration(path string) // Check for errors in configurations. // Applies to IdenticonConfiguration, ImageConfiguration // and Identicon types. CheckConfiguration() // Sets Identicon.Hash, Indenticon.Width & Identicon.Height // based on Identicon.IdenticonOptions.Square (bool). // // if: Identicon.IdenticonOptions.Square == TRUE, then // generate(set) Identicon.Hash suitable for square (1:1) aspect ratios // and set Identicon.width, Identicon.height = 1, 1 // else: // generate(set) Identicon.Hash suitable for wide (2:1) aspect ratios // and set Identicon.width, Identicon.height = 2, 1 GenerateHash() // Sets Identicon.Matrix based on some Identicon.IdenticonOptions. // Uses IdenticonConfiguration.Vertical (bool), IdenticonConfiguration.Invert (bool) // & IdenticonConfiguration.Symmetric (bool) to generate 8 different types of // matrices. // // Combinations: // vertical-inverted-symmetric, vertical-inverted-asymmetric, vertical-original-symmetric // vertical-original-asymmetric, horizontal-inverted-symmetric, horizontal-inverted-asymmetric // horizontal-original-symmetric, horizontal-original-asymmetric GenerateMatrix() // Printing the Identicon.Matrix to the terminal. // Identicon.IdenticonOptions.Border (bool) is used to determine whether // to print the identicon with/without border. Print() // Creates and saves an identicon as PNG image. Requires a `path` variable // to be passed, as an image saving directory or name. Size of the image // identicon depends on the Identicon.ImageOptions.Size property which is minimum // of either width & height of the image, divided by some value. SaveImage(path string) // Creates and saves an identicon as SVG. Requires a `path` variable // to be passed, as a SVG saving directory or name. Size of the SVG // identicon depends on the Cell Size of every block in the identicon, // which is currently hardcoded to 100 units. SaveSVG(path string) }
type ImageConfiguration ¶
type ImageConfiguration struct { Size string `json:"image-size"` // saves image with given resolution preset (S,M,L,X) Portrait bool `json:"image-portrait"` // saves image with portrait dimensions FG string `json:"fg"` // sets image's foreground color BG string `json:"bg"` // sets image's background color }
func (*ImageConfiguration) CheckConfiguration ¶
func (o *ImageConfiguration) CheckConfiguration()
Checks Identicon.ImageOptions for errors