svgpattern

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 11 Imported by: 0

README

svgpattern GitHub version codecov GoDoc Go Report Card

This project is in a very alpha stage for the moment.

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

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.

func New

func New(phrase string, options ...Option) Generator

New initialize a new Generator from the provided phrase and options.

type Option

type Option func(*generator)

An Option is a function that customize the Generator.

func RandomizeHue

func RandomizeHue(delta float64) Option

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

func RandomizeLightness(delta float64) Option

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

func RandomizeRotation(delta float64) Option

RandomizeRotation is a Generator option that randomize the rotation angle.

func RandomizeSaturation

func RandomizeSaturation(delta float64) Option

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

func RandomizeScale(delta float64) Option

RandomizeScale is a Generator option that randomize the scale factor.

func WithColor

func WithColor(hex string) Option

WithColor sets the background color. If the color is not valid a random one is chosen.

func WithHue added in v0.2.0

func WithHue(hue float64) Option

WithHue set the color hue of the HSL representation.

func WithLightness added in v0.2.0

func WithLightness(light float64) Option

WithLightness set the color lightness of the HSL representation.

func WithModel

func WithModel(models ...string) Option

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

func WithRotation(angle float64) Option

WithRotation is a Generator option that fix the pattern rotation transformation.

func WithRotationBetween

func WithRotationBetween(min, max float64) Option

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

func WithSaturation(sat float64) Option

WithSaturation set the color saturation of the HSL representation.

func WithScale

func WithScale(factor float64) Option

WithScale is a Generator option that fix the scale factor transformation.

func WithScaleBetween

func WithScaleBetween(min, max float64) Option

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.

Jump to

Keyboard shortcuts

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