Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Fennec-hub/three-wfc
/ functions
Functions
99 in github.com/Fennec-hub/three-wfc
⨍
Functions
99
◇
Types & classes
18
↓ 26 callers
Function
setStatus
Sets the status message in the control panel
live/src/main.ts:208
↓ 13 callers
Method
push
* Adds a key with a given entropy to the heap or updates it if it exists. * Throws an error if the heap is full and the key is new. * * @para
lib/WFCMinHeap.ts:54
↓ 12 callers
Function
copyReverse
(array: T[])
lib/utils/copyReverse.ts:1
↓ 9 callers
Function
setControlsDisabled
Toggles the disabled state of control buttons
live/src/main.ts:264
↓ 7 callers
Function
imgLoaderBatch
(srcs: string[])
lib/utils/imgLoader.ts:9
↓ 6 callers
Method
draw
* Draws the current state of the WFC grid onto the canvas. * Applies transformations (rotation, reflection) dynamically for debugging.
lib/WFC2D.ts:100
↓ 5 callers
Function
annotateTiles2DEdges
( tiles: WFCTile2D[], tolerance: number = 0.05, sobelThreshold: number = 30 )
lib/utils/annotateTiles2DEdges.ts:14
↓ 5 callers
Function
drawOverlayMessage
Draws a message overlay on the canvas
live/src/main.ts:249
↓ 4 callers
Function
extractEdgeLine
(direction: "top" | "bottom" | "left" | "right")
lib/utils/annotateTiles2DEdges.ts:167
↓ 4 callers
Function
quantizeChannel
(value: number, tolerance: number)
lib/utils/annotateTiles2DEdges.ts:89
↓ 4 callers
Function
updateCellsCount
()
live/src/main.ts:226
↓ 3 callers
Method
bubbleDown
Bubble an item down until its heap property is satisfied.
lib/WFCMinHeap.ts:231
↓ 3 callers
Method
bubbleUp
Bubble an item up until its heap property is satisfied.
lib/WFCMinHeap.ts:214
↓ 3 callers
Method
collapse
* * @returns
lib/WFC2DBuffer.ts:73
↓ 3 callers
Function
countSetBits
(bitmask: number)
lib/utils/countSetBits.ts:4
↓ 3 callers
Function
generateTimeSeed
()
lib/utils/prngSeedGenerators.ts:30
↓ 3 callers
Method
getWeight
(index: number)
lib/WFCTileBuffer.ts:70
↓ 3 callers
Method
indices
* Gets the indices of all set bits in the given mask. * @param index The index of the mask to check * @returns Array of indices of set bits, or
lib/WFCOptionsBuffer.ts:274
↓ 3 callers
Method
isEmpty
Is the heap empty?
lib/WFCMinHeap.ts:31
↓ 3 callers
Method
update
* Explicitly updates the entropy of an existing key. Does nothing if the key isn't present. * * @param key The key whose entropy to update. *
lib/WFCMinHeap.ts:81
↓ 2 callers
Method
_collapseCell
* Internal helper to perform the collapse logic for a specific cell index. * * @param index The index of the cell to collapse. * @returns `tr
lib/WFC2DBuffer.ts:136
↓ 2 callers
Method
_extractSetBits
* Helper method to extract set bit indices from a single chunk. * Uses bitwise operations for reliability and performance. * * @param chunk T
lib/WFCOptionsBuffer.ts:327
↓ 2 callers
Method
_reflect
* Creates a new WFCTile instance reflected across the specified axis. * Updates the edge tags accordingly. * @param axis - The axis of reflectio
lib/WFCTile2D.ts:195
↓ 2 callers
Function
clearPerfLog
Clears the performance log display
live/src/main.ts:213
↓ 2 callers
Method
clone
* Creates a new WFCTile instance that is a deep copy of this one. * @returns A new WFCTile instance.
lib/WFCTile2D.ts:144
↓ 2 callers
Method
collapse
()
lib/WFC2D.ts:80
↓ 2 callers
Method
collapseAll
* Repeatedly calls `collapse()` until all cells are collapsed or a contradiction occurs. * @returns `true` if the entire grid was successfully coll
lib/WFC2DBuffer.ts:82
↓ 2 callers
Method
collapsedTile
* Returns the collapsed cell tile's index, or `-1` if un-collapsed * * @param index * @returns The collapsed cell tile's index, `-1` if un-co
lib/WFC2DBuffer.ts:125
↓ 2 callers
Function
getAverageColor
(data: Uint8ClampedArray, tolerance = 0)
lib/utils/annotateTiles2DEdges.ts:99
↓ 2 callers
Method
mask
Returns a view (subarray) of the mask.
lib/WFCOptionsBuffer.ts:223
↓ 2 callers
Method
pop
* Removes and returns the key with the minimum entropy. * Returns undefined if the heap is empty. * * @returns The key with the minimum entro
lib/WFCMinHeap.ts:103
↓ 2 callers
Method
remove
* Removes an element associated with a specific key from the heap. * Returns true if the key was found and removed, false otherwise. * * @par
lib/WFCMinHeap.ts:153
↓ 2 callers
Method
size
Number of elements currently in the heap.
lib/WFCMinHeap.ts:26
↓ 2 callers
Method
swap
Swaps two elements in the heap arrays and updates the map
lib/WFCMinHeap.ts:194
↓ 2 callers
Function
updateStepLog
Updates the performance log for a single step
live/src/main.ts:233
↓ 1 callers
Method
_computeEntropy
Recomputes the Shannon entropy for a given cell
lib/WFC2DBuffer.ts:248
↓ 1 callers
Method
_initialize
()
lib/WFCTileBuffer.ts:30
↓ 1 callers
Method
_propagate
* Propagates constraints starting from a cell whose options have been reduced. * Uses an iterative approach with a stack and a Set to track items c
lib/WFC2DBuffer.ts:180
↓ 1 callers
Method
_rotate
* Creates a new WFCTile instance rotated clockwise by the specified amount. * Updates the edge tags accordingly. * @param rotation - The rotatio
lib/WFCTile2D.ts:155
↓ 1 callers
Method
addTile
(...tiles: WFCTile2D[])
lib/WFC2D.ts:45
↓ 1 callers
Method
clear
()
lib/WFC2D.ts:57
↓ 1 callers
Method
collapseCell
(index: number)
lib/WFC2D.ts:88
↓ 1 callers
Function
computeSobelMagnitude
( ctx: CanvasRenderingContext2D, w: number, h: number )
lib/utils/annotateTiles2DEdges.ts:124
↓ 1 callers
Method
copy
* Performs a deep copy of properties from a source tile into this tile. * Ensures arrays and Color objects are cloned, not just referenced. * @p
lib/WFCTile2D.ts:127
↓ 1 callers
Function
defineTiles
()
live/src/main.ts:132
↓ 1 callers
Function
displayPerformanceResults
(summary: PerformanceSummary)
live/src/performance.ts:313
↓ 1 callers
Method
enableAll
Enables all possible states (bits) for an item.
lib/WFCOptionsBuffer.ts:60
↓ 1 callers
Function
generateSeed
(input: string)
lib/utils/prngSeedGenerators.ts:8
↓ 1 callers
Method
getEdgeMask
(edge: number, index: number)
lib/WFCTileBuffer.ts:74
↓ 1 callers
Function
hashArray
(array: (string | number)[])
lib/utils/hashArray.ts:7
↓ 1 callers
Function
imgLoader
(src: string)
lib/utils/imgLoader.ts:1
↓ 1 callers
Function
indexedPrng
(seed: number)
lib/utils/prng.ts:26
↓ 1 callers
Method
init
()
lib/WFC2D.ts:61
↓ 1 callers
Function
initializeWFC
Initializes or re-initializes the WFC grid based on UI settings
live/src/main.ts:280
↓ 1 callers
Method
intersect
* Performs bitwise AND intersection between the mask at the given index * and the provided mask. Modifies the internal mask in place. * * @pa
lib/WFCOptionsBuffer.ts:157
↓ 1 callers
Function
loadTiles
( tileSet: "circuit" | "rail" | "road" )
live/src/performance.ts:32
↓ 1 callers
Method
peek
* Returns the minimum entropy without removing the element. * Returns undefined if the heap is empty.
lib/WFCMinHeap.ts:134
↓ 1 callers
Method
propagate
* Sets up a cell's neighboring constraints based on the current state of another cell. * * @param cellIdx The index of the reference cell * @
lib/WFCOptionsBuffer.ts:109
↓ 1 callers
Method
read
* Reads the current entropy associated with a given key. * Returns Positive Infinity if the key is not in the heap or out of range. * * @para
lib/WFCMinHeap.ts:42
↓ 1 callers
Method
reset
()
lib/WFCStackBuffer.ts:33
↓ 1 callers
Function
rgbaToHex
(r: number, g: number, b: number, a: number)
lib/utils/annotateTiles2DEdges.ts:93
↓ 1 callers
Function
runPerformanceTest
( tiles: WFCTile2D[], gridSize: number, numRuns: number, tileSetName: string )
live/src/performance.ts:139
↓ 1 callers
Function
segmentFromGradient
( line: Float32Array, threshold: number )
lib/utils/annotateTiles2DEdges.ts:61
↓ 1 callers
Method
setBit
* Sets a specific bit. * @param index The index of the cell * @param position The position of the bit to set/clear
lib/WFCOptionsBuffer.ts:46
↓ 1 callers
Method
size
Counts the number of enabled states (set bits).
lib/WFCOptionsBuffer.ts:203
↓ 1 callers
Method
transformClones
* Generates all unique transformed versions (clones) of this tile * based on the allowed rotations and reflections defined in its properties. *
lib/WFCTile2D.ts:108
↓ 1 callers
Function
updateCollapseAllLog
Updates the performance log after collapseAll
live/src/main.ts:238
↓ 1 callers
Function
updateTilesCount
(count: number)
live/src/main.ts:222
Method
clear
()
lib/WFCMinHeap.ts:188
Method
collapse
* Collapse the cell's option to a single * * @param index * @param position
lib/WFCOptionsBuffer.ts:77
Function
collapseAll
()
live/src/main.ts:416
Method
collapseAll
()
lib/WFC2D.ts:71
Method
collapseCell
* Collapses a specific cell to a randomly chosen valid tile based on current options * and propagates the constraints. * * @param index - The
lib/WFC2DBuffer.ts:100
Function
collapseStep
()
live/src/main.ts:376
Function
combineSeedValues
(values: (number | string)[])
lib/utils/prngSeedGenerators.ts:41
Method
constructor
( tiles: WFCTile2D[], cols: number, rows: number, seed?: number, noise: number = 0.00001
lib/WFC2DBuffer.ts:30
Method
constructor
(count: number)
lib/WFCStackBuffer.ts:7
Method
constructor
* Creates a new optimized Min Heap with a key-to-position map. * Assumes keys will be integers in the range [0, maxElements - 1]. * @param count
lib/WFCMinHeap.ts:16
Method
constructor
* Creates a new WFCTile instance. * @param config - Configuration object for the tile.
lib/WFCTile2D.ts:51
Method
constructor
(count: number, tiles: WFCTileBuffer)
lib/WFCOptionsBuffer.ts:22
Method
constructor
(tiles: WFCTile2D[], is2D: boolean = true)
lib/WFCTileBuffer.ts:12
Method
constructor
({ canvas, width, height, cellSize, seed, drawGrid, }: { canvas: HTMLCanvasEleme
lib/WFC2D.ts:17
Function
drawImage
( ctx: CanvasRenderingContext2D, img: HTMLImageElement, x: number, y: number, size: number, scale:
lib/utils/drawImage.ts:1
Function
drawRect
( ctx: CanvasRenderingContext2D, x: number, y: number, size: number, scale: number )
lib/utils/drawImage.ts:12
Method
edgeKey
(tile: number, edge: number)
lib/WFCTileBuffer.ts:36
Function
handleCanvasClick
(event: MouseEvent)
live/src/main.ts:497
Method
isCompleted
()
lib/WFC2DBuffer.ts:61
Function
main
()
live/src/performance.ts:357
Method
peekKey
* Returns the key with the minimum entropy without removing it. * Returns undefined if the heap is empty.
lib/WFCMinHeap.ts:142
Method
pop
()
lib/WFCStackBuffer.ts:24
Function
prng
(seed: number)
lib/utils/prng.ts:9
Function
prng2D
( seed: number, cols: number, origin: { x: number; y: number } )
lib/utils/prng2D.ts:10
Function
prng3D
( seed: number, width: number, height: number, origin: { x: number; y: number; z: number } )
lib/utils/prng3D.ts:11
Method
push
(value: number)
lib/WFCStackBuffer.ts:15
Method
put
* Adds a key with a given entropy to the heap or updates it if it exists. * Throws an error if the heap is full and the key is new. * * @para
lib/WFCMinHeap.ts:71
Method
remainingCells
()
lib/WFC2DBuffer.ts:65
Method
removeTile
(...tiles: WFCTile2D[])
lib/WFC2D.ts:49
Method
tile
* Gets the index of the single set bit, assuming the mask at 'index' * represents a collapsed state with exactly one option enabled. * Uses a fa
lib/WFCOptionsBuffer.ts:239
Method
weight
()
lib/WFCTile2D.ts:94