shapes

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FinderDrawConfig

type FinderDrawConfig struct {
	// Outer shape places outer container
	Outer FinderShapeDrawer
	// WhiteSpace used to create a mask to cut out inner part of the Outer shape
	WhiteSpace FinderShapeDrawer
	// Inner shape is drawn lastly, at the center of white space created by WhiteSpace shape
	Inner FinderShapeDrawer
}

FinderDrawConfig contains 3 FinderShapeDrawer functions, this allows to customize look of the inner and outer borders.

func RoundedFinderShape

func RoundedFinderShape(borderRadius float64) FinderDrawConfig

RoundedFinderShape draws finders with rounded corners.

borderRadius should be between 0 (square) and 0.5 (full circle). Other values are clamped to fit these requirements

func SquareFinderShape

func SquareFinderShape() FinderDrawConfig

SquareFinderShape is default shape for finders. Draws simple squares

type FinderShapeDrawer

type FinderShapeDrawer = func(ctx *gg.Context, x float64, y float64, size float64, modSize float64)

FinderShapeDrawer is general function for drawing finder shapes

This function should Draw any shape with top left corned on cords x and y with supplied size. FinderShapeDrawer should only Draw a path, but not fill anything, as it's done when calling this function

type ModuleDrawContext

type ModuleDrawContext struct {
	*gg.Context

	// X and Y is the coordinates of the top left corner of module
	X, Y float64
	// ModSize is the size of single module
	ModSize int
	// Gap should be subtracted from ModSize to keep padding between modules
	// Also, modules should be shifter by half of this value to properly centered
	//
	// This rule may be ignored if you need to connect modules in some specific way
	Gap float64

	// Neighbours contains a list of values for nearby neighbours
	Neighbours *ModuleNeighbours
}

ModuleDrawContext is a context for drawing single module on the image

type ModuleDrawer

type ModuleDrawer struct {
	Draw            func(ctx *ModuleDrawContext)
	NeedsNeighbours bool
}

ModuleDrawer is a function that should Draw a single module

func LineModuleShape added in v0.3.1

func LineModuleShape(borderRadius float64, vertical bool) ModuleDrawer

func RoundedModuleShape

func RoundedModuleShape(borderRadius float64, connected bool) ModuleDrawer

RoundedModuleShape draws module as square with rounded corners.

Supplied value is clamped between 0 (no roundness) and 0.5 (circle shape)

connected determines whether modules will be connected between each other

Note: when connected is true, this shape does not respect gaps (thus, gap will only be applied to finders)

func SquareModuleShape

func SquareModuleShape() ModuleDrawer

SquareModuleShape draws simple square as module

type ModuleNeighbours added in v0.3.0

type ModuleNeighbours struct {
	N, S, W, E bool
}

Jump to

Keyboard shortcuts

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