shape

package
v0.0.0-...-473980d Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CircleCollide

func CircleCollide(c0, c1 *Circle, padding float64) bool

CircleCollide returns true if c0 and c1 overlap, the padding is applied only once

func V2Distance

func V2Distance(v1, v2 V2) float64

V2Distance calculates the distance between V2 points in space

Types

type Circle

type Circle struct {
	Center V2
	Radius float64
	// contains filtered or unexported fields
}

Circle represents a cirle that can be drawn on a canvas

func NewCircle

func NewCircle(center V2, radius float64) *Circle

NewCircle creates a new circle

func (*Circle) Collides

func (c *Circle) Collides(circles []Circle, padding float64) bool

Collides returns true if the target circle overlaps with any of the circles provided

func (*Circle) NewSubCircle

func (c *Circle) NewSubCircle(radius float64, maxTries int, success func(*Circle) bool) (*Circle, bool)

NewSubCircle generates a new circle with the given radius that passes the success function. It will randomly generate sub circles within the radius of the circle until it fails maxTries times at which point it will return (nil, false)

func (*Circle) Overlap

func (c *Circle) Overlap(mask image.Image) float64

Overlap returns the portion of the circle that overlaps with the black pixels in the mask

func (*Circle) Render

func (c *Circle) Render(rgba color.RGBA, dest *image.RGBA)

Render draws the circle onto the destination image using the rgba color. It will use subpixel sampling for anti-aliasing

type V2

type V2 struct {
	X float64
	Y float64
}

V2 is a vector2 consisting of two float64s

func NewV2

func NewV2(x, y float64) V2

NewV2 creates a new V2

Jump to

Keyboard shortcuts

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