sirdsc

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 6 Imported by: 0

README

sirdsc

sirdsc is a simple package for generating single image random dot stereograms, or SIRDS, from height-maps.

Authors

Documentation

Index

Constants

View Source
const DefaultMaxImageDepth = 40

DefaultMaxImageDepth is the maximum depth used by ImageDepthMap if none is specified.

Variables

This section is empty.

Functions

func Generate

func Generate(out draw.Image, dm DepthMap, pat image.Image, partSize int)

Generate generates a new SIRDS from the depth map dm and draws it to out, using the pattern pat. partSize specifies the width of a single section of the generated stereogram. If partSize is less than or equal to zero, the width of pat is used. 100 is recommended as a good default, but this heavily depends on the physical size of the screen that the stereogram will be displayed on.

Types

type DepthMap

type DepthMap interface {
	// Bounds is the boundry of the depth map. This is analogous to
	// image.Image's Bounds() method.
	Bounds() image.Rectangle

	// At returns the depth at the given (x, y) coordinates. Zero is
	// considered to be the background plane, positive numbers are in
	// front of the background, and negative numbers are behind it.
	At(x, y int) int
}

A DepthMap maps pixel coordinates to depths. If you would like to use a traditional grayscale image as a depth map, see the ImageDepthMap type.

type ImageDepthMap

type ImageDepthMap struct {
	// The image.Image to pull pixel data from.
	Image image.Image

	// Max is the maximum depth that can be calculated from the pixels.
	// In other words, a pixel with a value of 0 yields a depth of 0,
	// while a pixel with a value of 255 yields this depth.
	//
	// If Max is zero, DefaultMaxImageDepth is used instead.
	Max int

	// If flat is true, all non-black pixels are considered to be Max.
	Flat bool

	// If Inverse is true, pixel values are considered to be the inverse
	// of normal. In other words, lower value pixels are considered to
	// be closer, while higher value pixels are considered to be further
	// away.
	Inverse bool
}

ImageDepthMap is a wrapper around an image.Image that allows it to be used as a DepthMap. It determines depth information from the values of the underlying pixels, considering higher value pixels to be closer and lower value pixels to be further away. Solid black pixels are considered to have a depth of zero. Alpha information is ignored.

func (ImageDepthMap) At

func (dm ImageDepthMap) At(x, y int) int

func (ImageDepthMap) Bounds

func (dm ImageDepthMap) Bounds() image.Rectangle

Bounds returns the same boundries as the underlying image.

type RandImage

type RandImage struct {
	Seed uint64
}

A RandImage deterministically generates random color values for each (x, y) coordinate, using itself as a seed. In other words, given two RandImages that are equal to each other, the color at the same (x, y) in each are also equal.

A RandImage has infinite size.

func (RandImage) At

func (img RandImage) At(x, y int) color.Color

func (RandImage) Bounds

func (img RandImage) Bounds() image.Rectangle

func (RandImage) ColorModel

func (img RandImage) ColorModel() color.Model

type SymmetricRandImage

type SymmetricRandImage struct {
	Seed uint64
}

A SymmetricRandImage is a variant of RandImage that is symmetric, such that a pixel at (a, b) is equal to a pixel at (b, a).

func (SymmetricRandImage) At

func (img SymmetricRandImage) At(x, y int) color.Color

func (SymmetricRandImage) Bounds

func (img SymmetricRandImage) Bounds() image.Rectangle

func (SymmetricRandImage) ColorModel

func (img SymmetricRandImage) ColorModel() color.Model

type TiledImage

type TiledImage struct {
	image.Image
}

A TiledImage extends another image by tiling it infinitely in every direction.

func (TiledImage) At

func (img TiledImage) At(x, y int) color.Color

func (TiledImage) Bounds

func (img TiledImage) Bounds() image.Rectangle

Directories

Path Synopsis
cmd
examples
web
Package spcg provides a stateless implementation of a PCG random number generator.
Package spcg provides a stateless implementation of a PCG random number generator.

Jump to

Keyboard shortcuts

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