Documentation ¶
Overview ¶
Package svgpattern generates 'random' svg patterns from text. The text is used to seed a sequence of random numbers that are used as parameters to generate a 'random' svg pattern.
Some of the parameters can be fixed or randomly assigned depending on the generator options.
Index ¶
- type Generator
- type Option
- func RandomizeHue(delta float64) Option
- func RandomizeLightness(delta float64) Option
- func RandomizeRotation(delta float64) Option
- func RandomizeSaturation(delta float64) Option
- func RandomizeScale(delta float64) Option
- func WithColor(hex string) Option
- func WithHue(hue float64) Option
- func WithLightness(light float64) Option
- func WithModel(models ...string) Option
- func WithRotation(angle float64) Option
- func WithRotationBetween(min, max float64) Option
- func WithSaturation(sat float64) Option
- func WithScale(factor float64) Option
- func WithScaleBetween(min, max float64) Option
- func WithoutColor() Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
type Generator interface { Options(...Option) Generate() (svg []byte, ok bool) Errors() []string Color() string }
A Generator produce the svg pattern based on the provided Options. If some errors occurs during the initialization and/or the generation they are available through Errors() method.
type Option ¶
type Option func(*generator)
An Option is a function that customize the Generator.
func RandomizeHue ¶
RandomizeHue is a Generator option that randomize the color hue (of the HSL representation). The (absolute value of) delta parameter is the maximal deviation in degree of the already provided color. This option should be used after WithColor.
func RandomizeLightness ¶
RandomizeLightness is a Generator option that randomize the color lightness (of the HSL representation). The (absolute value of) delta parameter is the maximal deviation of the already provided color with lightness in [0,1]. This option should be used after WithColor.
func RandomizeRotation ¶ added in v0.2.0
RandomizeRotation is a Generator option that randomize the rotation angle.
func RandomizeSaturation ¶
RandomizeSaturation is a Generator option that randomize the color saturation (of the HSL representation). The (absolute value of) delta parameter is the maximal deviation of the already provided color with saturation in [0,1]. This option should be used after WithColor.
func RandomizeScale ¶ added in v0.2.0
RandomizeScale is a Generator option that randomize the scale factor.
func WithColor ¶
WithColor sets the background color. If the color is not valid a random one is chosen.
func WithLightness ¶ added in v0.2.0
WithLightness set the color lightness of the HSL representation.
func WithModel ¶
WithModel is a Generator option that select the model from the list of 'valid' models. If only one valid model name is provided, it is used. If no such model is provided, then a random one is chosen among all models.
func WithRotation ¶
WithRotation is a Generator option that fix the pattern rotation transformation.
func WithRotationBetween ¶
WithRotationBetween is a Generator option that provide an interval [min, max] in witch the rotation angle of the patter should be randomly chosen.
func WithSaturation ¶ added in v0.2.0
WithSaturation set the color saturation of the HSL representation.
func WithScaleBetween ¶
WithScaleBetween is a Generator option that provide an interval [min, max] in witch the scale factor of the patter should be randomly chosen.
func WithoutColor ¶
func WithoutColor() Option
WithoutColor is a Generator option that remove the background color. If this option is used only the patterns are present, without a background. Using this option allows to stack the svg pattern on top of a gradient or image.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
svgpattern
Package main provides the command line interface to use svgpattern.
|
Package main provides the command line interface to use svgpattern. |
template
|
|
model
Package model provides the pattern templates for svgpattern.
|
Package model provides the pattern templates for svgpattern. |
tempfunc
Package tempfunc provide template functions.
|
Package tempfunc provide template functions. |