texture

package
v0.0.0-...-716269e Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package texture contains functions that populate images with texture.

  Halftone
  Dithers -
    Ordered
	Error Diffused

Index

Constants

This section is empty.

Variables

View Source
var (
	// B2Dither is the Bayer ordered dither matrix 2x2
	B2Dither = [][]float64{
		{1 / 4.0, 3 / 4.0},
		{4 / 4.0, 2 / 4.0},
	}

	// B4Dither is the Bayer ordered dither matrix 4x4
	B4Dither = [][]float64{
		{1 / 16.0, 9 / 16.0, 3 / 16.0, 11 / 16.0},
		{13 / 16.0, 5 / 16.0, 15 / 16.0, 7 / 16.0},
		{4 / 16.0, 12 / 16.0, 2 / 16.0, 10 / 16.0},
		{16 / 16.0, 8 / 16.0, 14 / 16.0, 6 / 16.0},
	}

	// B8Dither is the Bayer ordered dither matrix 8x8
	B8Dither = [][]float64{
		{0.015625, 0.515625, 0.140625, 0.640625, 0.046875, 0.546875, 0.171875, 0.671875},
		{0.765625, 0.265625, 0.890625, 0.390625, 0.796875, 0.296875, 0.921875, 0.421875},
		{0.203125, 0.703125, 0.078125, 0.578125, 0.234375, 0.734375, 0.109375, 0.609375},
		{0.953125, 0.453125, 0.828125, 0.328125, 0.984375, 0.484375, 0.859375, 0.359375},
		{0.062500, 0.562500, 0.187500, 0.687500, 0.031250, 0.531250, 0.156250, 0.656250},
		{0.812500, 0.312500, 0.937500, 0.437500, 0.781250, 0.281250, 0.906250, 0.406250},
		{0.250000, 0.750000, 0.125000, 0.625000, 0.218750, 0.718750, 0.093750, 0.593750},
		{1.000000, 0.500000, 0.875000, 0.375000, 0.968750, 0.468750, 0.843750, 0.343750},
	}
)

Ordered Dithers

Functions

func Halftone

func Halftone(dst draw.Image, c color.Color, perc, sep, rot float64, offs []float64)

Halftone renders colored halftone dots into the destination image. Line separation, rotation and percentage fill with a point offset (from {0, 0}) control the dot locations.

func OrderedDither

func OrderedDither(dst draw.Image, c1, c2 color.Color, t float64, mat [][]float64)

OrderedDither returns an ordered dithered image.

func ToOrderedDither

func ToOrderedDither(img image.Image, mat [][]float64) *image.Gray

ToOrderedDither takes the grayscale version of img and renders it as a black and white dithered image using the specified dither mask.

Types

type ErrorDiffusion

type ErrorDiffusion struct {
	Mat  [][]float64
	Stoc float64
}

ErrorDiffusion holds the error diffusion matrix and a stochastic value to use when noise is required.

func AtkinsonError

func AtkinsonError() *ErrorDiffusion

AtkinsonError returns the Atkinson error diffusion matrix 5x5

func BurkesError

func BurkesError() *ErrorDiffusion

BurkesError returns the Burkes error diffusion matrix 5x3 (Stuki without the last row)

func FSError

func FSError() *ErrorDiffusion

FSError returns the Floyd Steinberg error diffusion matrix 3x3

func JJNError

func JJNError() *ErrorDiffusion

JJNError returns the Jarvis Judice Ninke error diffusion matrix 5x5

func Sierra2Error

func Sierra2Error() *ErrorDiffusion

Sierra2Error returns the Sierra two row error diffusion matrix 5x3

func SierraError

func SierraError() *ErrorDiffusion

SierraError returns the Sierra error diffusion matrix 5x5

func SierraLError

func SierraLError() *ErrorDiffusion

SierraLError returns the Sierra lite error diffusion matrix 3x3

func Simple3Error

func Simple3Error() *ErrorDiffusion

Simple3Error returns a simple error diffusion matrix 3x3

func SimplestError

func SimplestError() *ErrorDiffusion

SimplestError returns a simpler error diffusion matrix 3x3

func StukiError

func StukiError() *ErrorDiffusion

StukiError returns the Stuki error diffusion matrix 5x5

func (*ErrorDiffusion) ErrorDither

func (ed *ErrorDiffusion) ErrorDither(dst draw.Image, c1, c2 color.Color, t float64, noise bool)

ErrorDither returns an error diffused dithered image using the error matrix. If noise is true, the diffusion weights are randomly +1/-1/0 times the stochastic value.

func (*ErrorDiffusion) ToErrorDither

func (ed *ErrorDiffusion) ToErrorDither(img image.Image) *image.Gray

ToErrorDither takes the grayscale version of img and renders it as a black and white dithered image using the specified error dither.

Jump to

Keyboard shortcuts

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