render

package
v0.0.0-...-2c3af24 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: BSD-3-Clause Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DynPatterns = map[string]image.Image{
	"rbow": &DynamicPattern{
		Color: func(x, y int, p *DynamicPattern) (float64, float64, float64) {
			xx := float64(x) / 26.0
			yy := float64(y) / 13.0
			r := 0.5 + 0.5*math.Cos(xx+p.Phase)
			g := 0.5 + 0.5*math.Sin(yy+p.Phase)
			b := 0.5 + 0.5*math.Sin(xx+p.Phase)*math.Cos(yy+p.Phase)
			return r, g, b
		},
	},

	"pastel": &DynamicPattern{
		Brightness: 0.5,
		ColFactor:  0.5,
		Freq:       5.0,

		Color: func(x, y int, p *DynamicPattern) (float64, float64, float64) {
			offset := 0.0
			v := math.Atan2(float64(x)-offset, float64(y)-offset) + p.Phase
			r := 0.5 + 0.5*math.Sin(v*p.Freq)
			g := 0.5 + 0.5*math.Cos(v*p.Freq)
			b := 0.5 + 0.5*math.Sin(v*p.Freq+6.28318/p.Luma)
			return r, g, b
		},
	},
}
View Source
var PrideFlags = map[string]color.Palette{
	"lgbti": color.Palette{
		color.NRGBA{0xe4, 0x03, 0x03, 0xff},
		color.NRGBA{0xff, 0x8c, 0x00, 0xff},
		color.NRGBA{0xff, 0xed, 0x00, 0xff},
		color.NRGBA{0x00, 0x80, 0x26, 0xff},
		color.NRGBA{0x00, 0x4d, 0xff, 0xff},
		color.NRGBA{0x75, 0x07, 0x87, 0xff},
	},
	"nonbinary": color.Palette{
		color.NRGBA{0x9c, 0x5c, 0xd4, 0xff},
		color.NRGBA{0xfc, 0xfc, 0xfc, 0xff},
		color.NRGBA{0xfc, 0xf4, 0x34, 0xff},
		color.NRGBA{0x2c, 0x2c, 0x2c, 0xff},
	},
	"trans": color.Palette{
		color.NRGBA{0x5b, 0xde, 0xfa, 0xff},
		color.NRGBA{0xf5, 0xa9, 0xb8, 0xff},
		color.NRGBA{0xff, 0xff, 0xff, 0xff},
		color.NRGBA{0xf5, 0xa9, 0xb8, 0xff},
		color.NRGBA{0x5b, 0xde, 0xfa, 0xff},
	},
}

Functions

func ImgColorFilter

func ImgColorFilter(img *image.NRGBA, from, to color.NRGBA) *image.NRGBA

ImgColorFilter replaces `from` with `to` in `img`, and sets all other pixels to color.Transparent

func NewPrideImage

func NewPrideImage(p color.Palette, bounds image.Rectangle) image.Image

func ReadImage

func ReadImage(path string) (*image.NRGBA, error)

func RenderText

func RenderText(text string, scale float64, texture, bgTex image.Image) *image.NRGBA

func RotateImage90

func RotateImage90(img *image.NRGBA) (rotated *image.NRGBA)

func ScaleImage

func ScaleImage(img image.Image, factorX, factorY float64, highQuality bool) (scaled *image.NRGBA)

func WriteImage

func WriteImage(path string, img image.Image) error

Types

type DynamicPattern

type DynamicPattern struct {
	Pattern

	Color func(x, y int, p *DynamicPattern) (float64, float64, float64) // should return rgb in [0,1] range

	Luma  float64 // color parameter
	Freq  float64 // frequency parameter
	Phase float64 // phase parameter

	Brightness float64 // additive base brightness
	ColFactor  float64 // Pattern intensity
}

func (*DynamicPattern) At

func (c *DynamicPattern) At(x, y int) color.Color

type Pattern

type Pattern struct {
}

Pattern provides infinite algorithmically generated Patterns and implements the image.Image interface.

func (*Pattern) At

func (c *Pattern) At(x, y int) color.Color

func (*Pattern) Bounds

func (c *Pattern) Bounds() image.Rectangle

func (*Pattern) ColorModel

func (c *Pattern) ColorModel() color.Model

Image interface

func (*Pattern) ToFixedImage

func (p *Pattern) ToFixedImage(bounds image.Rectangle) *image.NRGBA

type StripePattern

type StripePattern struct {
	Pattern
	Size    int
	Palette color.Palette
}

func (*StripePattern) At

func (c *StripePattern) At(x, y int) color.Color

Jump to

Keyboard shortcuts

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