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 ...Drawer) 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 Drawer

type Drawer interface {
	Draw(img draw.Image, x, y int) error
}

type Filleder

type Filleder interface {
	Filled() bool
	SetFilled(bool)
}

type Filler

type Filler interface {
	Fill() color.Color
	SetFill(fill color.Color)
}

type Option

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

type Radiuser

type Radiuser interface {
	Radius() int
	SetRadius(radius int)
}

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 Rectangler

type Rectangler interface {
	Rect() image.Rectangle
	SetRect(image.Rectangle)
}

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 Shaper

type Shaper interface {
	Drawer
	Filler
}

func New

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

type Sideser

type Sideser interface {
	Sides() int
	SetSides(sides int)
}

Jump to

Keyboard shortcuts

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