c

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColourWhite   = BrushColour{R: 1.0, G: 1.0, B: 1.0, A: 1.0}
	ColourRed     = BrushColour{R: 1.0, G: 0.0, B: 0.0, A: 1.0}
	ColourGreen   = BrushColour{R: 0.0, G: 1.0, B: 0.0, A: 1.0}
	ColourBlue    = BrushColour{R: 0.0, G: 0.0, B: 1.0, A: 1.0}
	ColourCyan    = BrushColour{R: 0.0, G: 1.0, B: 1.0, A: 1.0}
	ColourMagenta = BrushColour{R: 1.0, G: 0.0, B: 1.0, A: 1.0}
	ColourYellow  = BrushColour{R: 1.0, G: 1.0, B: 0.0, A: 1.0}
	ColourBlack   = BrushColour{R: 0.0, G: 0.0, B: 0.0, A: 1.0}
)

Functions

func BlendAlphaOverlay

func BlendAlphaOverlay(cB, cA float64) (cO float64)

BlendAlphaOverlay blends A and B alpha channels into O channel. B is the base layer, i.e. the bottom layer. A is the applied layer, i.e. the top layer.

func BlendChannelOverlay

func BlendChannelOverlay(cB, cA, aB, aA float64) (cO float64)

BlendChannelOverlay blends A and B channels into O channel. B is the base layer, i.e. the bottom layer. A is the applied layer, i.e. the top layer.

func BlendColourOverlay

func BlendColourOverlay(cB, cA color.Color) (cO color.Color)

BlendColourOverlay blends A and B pixels into O pixel. B is the base layer, i.e. the bottom layer. A is the applied layer, i.e. the top layer.

func BlendImages

func BlendImages(iB *image.NRGBA, iA *image.NRGBA) (iO *image.NRGBA, err error)

BlendImages blends A and B images into O image. B is the base layer, i.e. the bottom layer. A is the applied layer, i.e. the top layer.

func ConvertImageToNRGBA

func ConvertImageToNRGBA(in image.Image) (out *image.NRGBA)

func ConvertImageToRGBA

func ConvertImageToRGBA(in image.Image) (out *image.RGBA)

func CreateCaptcha

func CreateCaptcha(w, h uint) (c *m.Captcha, err error)

func CreateCaptchaImage

func CreateCaptchaImage(w, h uint, useSample bool, blend bool) (canvas *image.NRGBA, ringCount uint, err error)

func DegreeToRadian

func DegreeToRadian(degree float64) (radian float64)

func DeleteImageFile

func DeleteImageFile(filePath string) (err error)

func DrawImageToCanvas

func DrawImageToCanvas(in *image.RGBA, canvas image.Rectangle) (out *image.NRGBA)

DrawImageToCanvas draws an image on another canvas.

func DrawLineWithSimpleBrush

func DrawLineWithSimpleBrush(canvas *image.NRGBA, br *SimpleBrush, p1, p2 Point2D, blend bool)

DrawLineWithSimpleBrush draws a straight line using a simple brush.

func DrawRingWithSimpleBrush

func DrawRingWithSimpleBrush(canvas *image.NRGBA, br *SimpleBrush, center Point2D, radius float64, daDegree float64, useSample bool, blend bool)

func FileNameWithoutExtension

func FileNameWithoutExtension(fileName string) string

func FillCanvasWithColour

func FillCanvasWithColour(canvas *image.NRGBA, col color.Color)

FillCanvasWithColour fills the canvas with colour.

func FillCanvasWithHGradient

func FillCanvasWithHGradient(canvas *image.NRGBA, cL, cR BrushColour) (err error)

FillCanvasWithHGradient fills the canvas with a horizontal gradient. cL specifies the left side colour and cR is the right side colour.

func FillCanvasWithVGradient

func FillCanvasWithVGradient(canvas *image.NRGBA, cT, cB BrushColour) (err error)

FillCanvasWithVGradient fills the canvas with a vertical gradient. cT specifies the top side colour and cB is the bottom side colour.

func GetColorComponentsPM

func GetColorComponentsPM(c color.Color) (r, g, b, a float64)

GetColorComponentsPM extracts colour's components as usable floating point numbers. The returned values are pre-multiplied with alpha channel.

func GetColorComponentsS

func GetColorComponentsS(c color.Color) (r, g, b, a float64)

GetColorComponentsS extracts colour's components as usable floating point numbers. The returned values use straight alpha channel.

func GetImageFromFilePath

func GetImageFromFilePath(filePath string) (img image.Image, err error)

func MakeFileName

func MakeFileName(id string) (fileName string)

func MakeRGBA64

func MakeRGBA64(r, g, b, a float64) color.RGBA64

MakeRGBA64 creates an RGBA64 colour with the provided channels.

func MakeRecordFilePath

func MakeRecordFilePath(imagesFolder string, id string) (path string)

func MinInt

func MinInt(a, b int) (min int)

func MinUint

func MinUint(a, b uint) (min uint)

func RadianToDegree

func RadianToDegree(radian float64) (degree float64)

func SaveImageAsPngFile

func SaveImageAsPngFile(img image.Image, filePath string) (err error)

func UseSimpleBrush

func UseSimpleBrush(canvas *image.NRGBA, brush *SimpleBrush, blend bool, u Point2D)

UseSimpleBrush creates a point using a simple brush.

func UseSimpleBrushS

func UseSimpleBrushS(canvas *image.NRGBA, brush *SimpleBrush, blend bool, u Point2D)

UseSimpleBrushS creates a point using a simple brush with a sample.

func UseSolidBrush

func UseSolidBrush(canvas *image.NRGBA, brush *SolidBrush, u Point2D)

UseSolidBrush creates a point using a solid brush.

Types

type BrushColour

type BrushColour struct {
	R float64
	G float64
	B float64
	A float64
}

func (BrushColour) PremultipliedToStraight

func (bc BrushColour) PremultipliedToStraight() (out BrushColour)

func (BrushColour) RGBA

func (bc BrushColour) RGBA() (r, g, b, a uint32)

RGBA method of the color.Color interface.

func (BrushColour) StraightToPremultiplied

func (bc BrushColour) StraightToPremultiplied() (out BrushColour)

type Distance

type Distance = float64

func Distance2D

func Distance2D(a, b Point2D) (s Distance)

type Point2D

type Point2D struct {
	X float64
	Y float64
}

type SimpleBrush

type SimpleBrush struct {
	InnerRadius float64
	OuterRadius float64
	Colour      BrushColour
	// contains filtered or unexported fields
}

SimpleBrush is a basic round brush with soft edges.

func (*SimpleBrush) GetSample

func (sb *SimpleBrush) GetSample() (sample *image.NRGBA)

type SolidBrush

type SolidBrush struct {
	InnerRadius float64
	Colour      BrushColour
}

SolidBrush is a basic round brush without any soft edges.

Jump to

Keyboard shortcuts

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