shapes

package
v0.0.0-...-2424c55 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: GPL-3.0, 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. This satisfies the Filler, Radiuser, Drawer, and Stringer interfaces.

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 Filler

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

type Option

type Option struct {
	Fill   color.Color
	Radius int
}

type Radiuser

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

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

This satisfies the Filler, Radiuser, Drawer, Sideser, and Stringer interfaces.

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 // Draw()
	Filler // Fill(); SetFill()
}

func New

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

Factory function: The returned Shaper can only call Shaper methods unless we use type assertion: see main() in ../main.go for examples.

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