Documentation
¶
Index ¶
- type AppliedAlgorithm
- type BaseModel
- func (baseModel *BaseModel) ClearBase(specificModel AppliedAlgorithm)
- func (baseModel *BaseModel) Generate(specificModel AppliedAlgorithm)
- func (baseModel *BaseModel) IsGenerationSuccessful() bool
- func (baseModel *BaseModel) Iterate(specificModel AppliedAlgorithm, iterations int) bool
- func (baseModel *BaseModel) Observe(specificModel AppliedAlgorithm) bool
- func (baseModel *BaseModel) SetSeed(seed int64)
- func (baseModel *BaseModel) SingleIteration(specificModel AppliedAlgorithm) bool
- type GeneratedImage
- type Generator
- type Inversion
- type Iterator
- type Neighbor
- type OverlappingModel
- func (model *OverlappingModel) Clear()
- func (model *OverlappingModel) Generate() (image.Image, bool)
- func (model *OverlappingModel) Iterate(iterations int) (image.Image, bool, bool)
- func (model *OverlappingModel) OnBoundary(x, y int) bool
- func (model *OverlappingModel) Propagate() bool
- func (model *OverlappingModel) Render() image.Image
- func (model *OverlappingModel) RenderCompleteImage() image.Image
- func (model *OverlappingModel) RenderIncompleteImage() image.Image
- type Pattern
- type SimpleTiledData
- type SimpleTiledModel
- func (model *SimpleTiledModel) Clear()
- func (model *SimpleTiledModel) Generate() (image.Image, bool)
- func (model *SimpleTiledModel) Iterate(iterations int) (image.Image, bool, bool)
- func (model *SimpleTiledModel) OnBoundary(x, y int) bool
- func (model *SimpleTiledModel) Propagate() bool
- func (model *SimpleTiledModel) Render() image.Image
- func (model *SimpleTiledModel) RenderCompleteImage() image.Image
- func (model *SimpleTiledModel) RenderIncompleteImage() image.Image
- type Tile
- type TilePattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppliedAlgorithm ¶
type BaseModel ¶
type BaseModel struct {
InitiliazedField bool // Generation Initialized
RngSet bool // Random number generator set by user
GenerationSuccessful bool // Generation has run into a contradiction
Wave [][][]bool // All possible patterns (t) that could fit coordinates (x, y)
Changes [][]bool // Changes made in interation of propagation
Stationary []float64 // Array of weights (by frequency) for each pattern (matches index in patterns field)
T int // Count of patterns
Periodic bool // Output is periodic (ie tessellates)
Fmx, Fmy int // Width and height of output
Rng func() float64 // Random number generator supplied at generation time
}
func (*BaseModel) ClearBase ¶
func (baseModel *BaseModel) ClearBase(specificModel AppliedAlgorithm)
*
- Clear the internal state to start a new generation
func (*BaseModel) Generate ¶
func (baseModel *BaseModel) Generate(specificModel AppliedAlgorithm)
*
- Execute a complete new generation until success or failure.
func (*BaseModel) Iterate ¶
func (baseModel *BaseModel) Iterate(specificModel AppliedAlgorithm, iterations int) bool
*
- Execute a fixed number of iterations. Stop when the generation succeedes or fails.
func (*BaseModel) Observe ¶
func (baseModel *BaseModel) Observe(specificModel AppliedAlgorithm) bool
*
- Observe
- returns: finished (bool)
func (*BaseModel) SetSeed ¶
*
- Set the seed for the random number generator. Useful for a stable testing environment.
func (*BaseModel) SingleIteration ¶
func (baseModel *BaseModel) SingleIteration(specificModel AppliedAlgorithm) bool
*
- Execute a single iteration
- returns: finished (bool)
type GeneratedImage ¶
type GeneratedImage struct {
// contains filtered or unexported fields
}
General struct for common functionality between CompleteImage and IncompleteImage
func (GeneratedImage) Bounds ¶
func (gi GeneratedImage) Bounds() image.Rectangle
func (GeneratedImage) ColorModel ¶
func (gi GeneratedImage) ColorModel() color.Model
type Neighbor ¶
type Neighbor struct {
Left string // Mathces Tile.Name
LeftNum int // Default to 0
Right string // Mathces Tile.Name
RightNum int // Default to 0
}
Information on which tiles can be neighbors
type OverlappingModel ¶
type OverlappingModel struct {
*BaseModel // Underlying model of generic Wave Function Collapse algorithm
N int // Size of patterns (ie pixel distance of influencing pixels)
Colors []color.Color // Array of unique colors in input
Ground int // Id of the specific pattern to use as the bottom of the generation. A value of -1 means that this is unset
Patterns []Pattern // Array of unique patterns in input
Propagator [][][][]int // Table of which patterns (t2) mathch a given pattern (t1) at offset (dx, dy) [t1][dx][dy][t2]
Fmxmn, Fmymn int // Width and height of output, minus n
}
*
- OverlappingModel Type
func NewOverlappingModel ¶
func NewOverlappingModel(img image.Image, n, width, height int, periodicInput, periodicOutput bool, symmetry int, ground bool) *OverlappingModel
*
- NewOverlappingModel
- @param {image.Image} img The source image
- @param {int} N Size of the patterns
- @param {int} width The width of the generated image
- @param {int} height The height of the generated image
- @param {bool} periodicInput Whether the source image is to be considered as periodic / as a repeatable texture
- @param {bool} periodicOutput Whether the generation should be periodic / a repeatable texture
- @param {int} symmetry Allowed symmetries from 1 (no symmetry) to 8 (all mirrored / rotated variations)
- @param {int} [ground=0] Id of the specific pattern to use as the bottom of the generation ( see https://github.com/mxgmn/WaveFunctionCollapse/issues/3#issuecomment-250995366 )
- @return *OverlappingModel A pointer to a new copy of the model
func (*OverlappingModel) Clear ¶
func (model *OverlappingModel) Clear()
*
- Clear the internal state, then set ground pattern
func (*OverlappingModel) Generate ¶
func (model *OverlappingModel) Generate() (image.Image, bool)
*
- Retrieve the RGBA data
- returns: Image, successful
func (*OverlappingModel) OnBoundary ¶
func (model *OverlappingModel) OnBoundary(x, y int) bool
*
- OnBoundary
func (*OverlappingModel) Propagate ¶
func (model *OverlappingModel) Propagate() bool
*
- Propagate
- return: bool, change occured in this iteration
func (*OverlappingModel) Render ¶
func (model *OverlappingModel) Render() image.Image
*
- Retrieve the RGBA data
- returns: Image
func (*OverlappingModel) RenderCompleteImage ¶
func (model *OverlappingModel) RenderCompleteImage() image.Image
*
- Create a image.Image holding the data for a complete image
func (*OverlappingModel) RenderIncompleteImage ¶
func (model *OverlappingModel) RenderIncompleteImage() image.Image
*
- Create a image.Image holding the data for an incomplete image
type SimpleTiledData ¶
type SimpleTiledData struct {
Unique bool // False if each tile can have variants. (Default to false?)
TileSize int // Default to 16
Tiles []Tile // List of all possible tiles, not including inversions
Neighbors []Neighbor // List of possible connections between tiles
}
Parsed data supplied by user
type SimpleTiledModel ¶
type SimpleTiledModel struct {
*BaseModel // Underlying model of generic Wave Function Collapse algorithm
TileSize int // The size in pixels of the length and height of each tile
Tiles []TilePattern // List of all possible tiles as images, including inversions
Propagator [][][]bool // All possible connections between tiles
}
*
- SimpleTiledModel Type
func NewSimpleTiledModel ¶
func NewSimpleTiledModel(data SimpleTiledData, width, height int, periodic bool) *SimpleTiledModel
*
- NewSimpleTiledModel
- @param {object} data Tiles and constraints definitions
- @param {int} width The width of the generation, in terms of tiles (not pixels)
- @param {int} height The height of the generation, in terms of tiles (not pixels)
- @param {bool} periodic Whether the source image is to be considered as periodic / as a repeatable texture
- @return *SimpleTiledModel A pointer to a new copy of the model
func (*SimpleTiledModel) Clear ¶
func (model *SimpleTiledModel) Clear()
*
- Clear the internal state, then set ground pattern
func (*SimpleTiledModel) Generate ¶
func (model *SimpleTiledModel) Generate() (image.Image, bool)
*
- Retrieve the RGBA data
- returns: Image, successful
func (*SimpleTiledModel) OnBoundary ¶
func (model *SimpleTiledModel) OnBoundary(x, y int) bool
*
- OnBoundary
func (*SimpleTiledModel) Propagate ¶
func (model *SimpleTiledModel) Propagate() bool
*
- Propagate
- return: bool, change occured in this iteration
func (*SimpleTiledModel) Render ¶
func (model *SimpleTiledModel) Render() image.Image
*
- Retrieve the RGBA data
- returns: Image
func (*SimpleTiledModel) RenderCompleteImage ¶
func (model *SimpleTiledModel) RenderCompleteImage() image.Image
*
- Create a image.Image holding the data for a complete image
func (*SimpleTiledModel) RenderIncompleteImage ¶
func (model *SimpleTiledModel) RenderIncompleteImage() image.Image
*
- Create a image.Image holding the data for an incomplete image
Source Files
¶
Click to show internal directories.
Click to hide internal directories.

