genart

package module
v0.0.0-...-1e9f248 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 8 Imported by: 0

README

sketchy

Code I use over and over while making generative art

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Pi    = math.Pi
	Tau   = 2 * math.Pi
	Sqrt2 = math.Sqrt2
	Sqrt3 = math.Sqrt(3)
)

Functions

func Clamp

func Clamp(a float64, b float64, c float64) float64

func Deg2Rad

func Deg2Rad(f float64) float64

func Distance

func Distance(p Point, q Point) float64

func Gcd

func Gcd(a int, b int) int

func Lerp

func Lerp(a float64, b float64, i float64) float64

func Linspace

func Linspace(i float64, j float64, n int, b bool) []float64

func Map

func Map(a float64, b float64, c float64, d float64, i float64) float64

func Rad2Deg

func Rad2Deg(f float64) float64

func Shuffle

func Shuffle(p *[]Point)

func SquaredDistance

func SquaredDistance(p Point, q Point) float64

Types

type Curve

type Curve struct {
	Points []Point
	Closed bool
}

func Chaikin

func Chaikin(c Curve, q float64, n int) Curve

func GenLissajous

func GenLissajous(l Lissajous, n int, offset Point, s float64) Curve

func (*Curve) Last

func (c *Curve) Last() Point

func (*Curve) Length

func (c *Curve) Length() float64

type Line

type Line struct {
	P Point
	Q Point
}

func (Line) Length

func (l Line) Length() float64

func (Line) Lerp

func (l Line) Lerp(i float64) Point

func (Line) Midpoint

func (l Line) Midpoint() Point

func (Line) String

func (l Line) String() string

type Lissajous

type Lissajous struct {
	Nx int
	Ny int
	Px float64
	Py float64
}

type Point

type Point struct {
	X float64
	Y float64
}

func CartesianToScreen

func CartesianToScreen(p []Point, o Point, s float64) []Point

func Midpoint

func Midpoint(p Point, q Point) Point

func PaduaPoints

func PaduaPoints(n int) []Point

func (Point) Lerp

func (p Point) Lerp(a Point, i float64) Point

func (Point) String

func (p Point) String() string

type Rect

type Rect struct {
	X float64
	Y float64
	W float64
	H float64
}

func (*Rect) ContainsPoint

func (r *Rect) ContainsPoint(p Point) bool

type Slider

type Slider struct {
	Name   string
	Pos    Point
	Width  float64
	Height float64
	MinVal float64
	MaxVal float64
	Val    float64
	Incr   float64
}

func NewIntStepSlider

func NewIntStepSlider(name string, minVal int, maxVal int) Slider

func NewRadiansSlider

func NewRadiansSlider(name string, steps int) Slider

func (*Slider) AutoHeight

func (s *Slider) AutoHeight(ctx *gg.Context)

func (*Slider) CheckAndUpdate

func (s *Slider) CheckAndUpdate() error

func (*Slider) Draw

func (s *Slider) Draw(ctx *gg.Context)

func (*Slider) GetPercentage

func (s *Slider) GetPercentage() float64

func (*Slider) GetRect

func (s *Slider) GetRect(ctx *gg.Context) Rect

func (*Slider) IsInside

func (s *Slider) IsInside(x float64, y float64) bool

func (*Slider) Update

func (s *Slider) Update(x float64)

Jump to

Keyboard shortcuts

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