Documentation ¶
Index ¶
Constants ¶
const DefaultMaxImageDepth = 40
DefaultMaxImageDepth is the maximum depth used by ImageDepthMap if none is specified.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
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) ColorModel ¶
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) Bounds ¶
func (img SymmetricRandImage) Bounds() image.Rectangle
func (SymmetricRandImage) ColorModel ¶
func (img SymmetricRandImage) ColorModel() color.Model
type TiledImage ¶
A TiledImage extends another image by tiling it infinitely in every direction.
func (TiledImage) Bounds ¶
func (img TiledImage) Bounds() image.Rectangle