shapes

package
v0.0.0-...-5daf3a2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MIT, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawShapes

func DrawShapes(img draw.Image, x, y int, shapes ...Shaper) error

func FilledImage

func FilledImage(width, height int, fill color.Color) draw.Image

func SaveImage

func SaveImage(img image.Image, filename string) error

Types

type Circle

type Circle struct {
	// contains filtered or unexported fields
}

The zero value is invalid! Use NewCircle() to create a valid Circle.

func NewCircle

func NewCircle(fill color.Color, radius int) *Circle

By calling newShape() we pass on any checking to newShape() without having to know what if any is required.

func (*Circle) Draw

func (circle *Circle) Draw(img draw.Image, x, y int) error

func (Circle) Fill

func (shape Circle) Fill() color.Color

func (*Circle) Radius

func (circle *Circle) Radius() int

func (*Circle) SetFill

func (shape *Circle) SetFill(fill color.Color)

func (*Circle) SetRadius

func (circle *Circle) SetRadius(radius int)

func (*Circle) String

func (circle *Circle) String() string

type CircularShaper

type CircularShaper interface {
	Shaper // Fill(); SetFill(); Draw()
	Radius() int
	SetRadius(radius int)
}

type Option

type Option struct {
	Fill   color.Color
	Radius int
	Rect   image.Rectangle
	Filled bool
}

type Rectangle

type Rectangle struct {
	image.Rectangle
	// contains filtered or unexported fields
}

The zero value is invalid! Use NewRectangle() to create a valid Rectangle.

func NewRectangle

func NewRectangle(fill color.Color, rect image.Rectangle) *Rectangle

func (*Rectangle) Draw

func (rectangle *Rectangle) Draw(img draw.Image, x, y int) error

x, y are the top-left (for radius-based shapes they are the middle)

func (Rectangle) Fill

func (shape Rectangle) Fill() color.Color

func (*Rectangle) Filled

func (rectangle *Rectangle) Filled() bool

func (*Rectangle) Rect

func (rectangle *Rectangle) Rect() image.Rectangle

func (*Rectangle) SetFill

func (shape *Rectangle) SetFill(fill color.Color)

func (*Rectangle) SetFilled

func (rectangle *Rectangle) SetFilled(filled bool)

func (*Rectangle) SetRect

func (rectangle *Rectangle) SetRect(rect image.Rectangle)

type RectangularShaper

type RectangularShaper interface {
	Shaper // Fill(); SetFill(); Draw()
	Rect() image.Rectangle
	SetRect(image.Rectangle)
	Filled() bool
	SetFilled(bool)
}

type RegularPolygon

type RegularPolygon struct {
	*Circle
	// contains filtered or unexported fields
}

The zero value is invalid! Use NewRegularPolygon() to create a valid RegularPolygon.

func NewRegularPolygon

func NewRegularPolygon(fill color.Color, radius, sides int) *RegularPolygon

func (*RegularPolygon) Draw

func (polygon *RegularPolygon) Draw(img draw.Image, x, y int) error

func (RegularPolygon) Fill

func (shape RegularPolygon) Fill() color.Color

func (RegularPolygon) SetFill

func (shape RegularPolygon) SetFill(fill color.Color)

func (*RegularPolygon) SetSides

func (polygon *RegularPolygon) SetSides(sides int)

func (*RegularPolygon) Sides

func (polygon *RegularPolygon) Sides() int

func (*RegularPolygon) String

func (polygon *RegularPolygon) String() string

type RegularPolygonalShaper

type RegularPolygonalShaper interface {
	CircularShaper // Fill(); SetFill(); Draw(); Radius(); SetRadius()
	Sides() int
	SetSides(sides int)
}

type Shaper

type Shaper interface {
	Fill() color.Color
	SetFill(fill color.Color)
	Draw(img draw.Image, x, y int) error
}

func New

func New(shape string, option Option) (Shaper, error)

Jump to

Keyboard shortcuts

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