Documentation ¶
Overview ¶
Painter is a simple image.NRGBA utility packages which helps you with drawing on images.
Index ¶
- Variables
- func Decode(r io.Reader) (image.Image, error)
- func Draw(img *image.NRGBA, rect image.Rectangle, process PixelProcessor)
- func DrawColor(img *image.NRGBA, rect image.Rectangle, c color.NRGBA)
- func DrawLinearGradient(img *image.NRGBA, rect image.Rectangle, angle float64, ...)
- func DrawRadialGradient(img *image.NRGBA, rect image.Rectangle, startColor, endColor color.NRGBA, ...)
- func MergeColors(background, foreground color.NRGBA) color.NRGBA
- func MixNRGBA(a float64, x, y color.NRGBA) color.NRGBA
- func New(width, height int) *image.NRGBA
- func Paste(dst *image.NRGBA, src image.Image, x, y int)
- func SaveJPEG(img image.Image, path string, o *jpeg.Options) error
- func SavePNG(img image.Image, path string) error
- type PixelProcessor
Constants ¶
This section is empty.
Variables ¶
var Workers int = runtime.NumCPU()
Workers defines the goroutines count used for some methods like Draw.
Functions ¶
func Decode ¶ added in v0.1.0
Decode calls the image.Decode and returns the image.
It's useful when you're not sure about the image type and also want to be safe from it.
func Draw ¶ added in v0.1.0
func Draw(img *image.NRGBA, rect image.Rectangle, process PixelProcessor)
Draw is a low-level method which loops through each pixel in rect's range concurrently and sets the merged & processed color on them.
func DrawColor ¶ added in v0.1.0
DrawColor replaces each pixel's color with the specified color c. It fully takes care of transparent colors.
func DrawLinearGradient ¶ added in v0.1.0
func DrawLinearGradient(img *image.NRGBA, rect image.Rectangle, angle float64, startColor, endColor color.NRGBA)
LinearGradient draws a linear gradient on the image from startColor to endColor with in the passed angle in radians. It fully takes care of transparent colors.
func DrawRadialGradient ¶ added in v0.1.0
func DrawRadialGradient(img *image.NRGBA, rect image.Rectangle, startColor, endColor color.NRGBA, center image.Point)
DrawRadialGradient draws a radial gradient on the image from startColor to endColor. startColor starts from provided center point. It fully takes care of transparent colors.
func MergeColors ¶ added in v0.1.0
MergeNRGBA merges two image/color.NRGBA colors.
func MixNRGBA ¶ added in v0.1.0
MixNRGBA merges two colors with the provided alpha.
"a" should be between 0 and 1.
TODO: Support multiple colors
func New ¶
New returns a new image.NRGBA in the specified width and height.
Types ¶
type PixelProcessor ¶ added in v0.1.0
PixelProcessor returns a image/color.NRGBA for the specified image coordinates. It will be called concurrently.