Skip to content

groundTextures ​

Namespace of @v12-engine/client/ground

Members ​

adjustColor beta ​

ts
export declare function adjustColor(color: Readonly<Rgb>, adjust: GroundAdjust | undefined): [number, number, number];

A colour as an adjustment makes it, 0..1 a channel: tinted, then its saturation, contrast and brightness, in the order a page's CSS filters saturate, contrast and brightness take them (the editor's preview is made of those)

adjustPixels beta ​

ts
export declare function adjustPixels(pixels: Uint8Array, adjust: GroundAdjust | undefined): Uint8Array;

The pixels of a picture (RGBA, 0..255) as an adjustment makes them, in place. Nothing is done for none

adjusts beta ​

ts
adjusts: (adjust: GroundAdjust | undefined) => adjust is GroundAdjust

Whether an adjustment changes anything

BLEND_DEPTH beta ​

ts
BLEND_DEPTH = 0.2

How deep two tiles' heights blend into each other where they meet (TileLook.blendDepth), when a tile does not say: a crisp, ragged edge, the higher picture over the lower (grass tufts over dirt)

definePattern beta ​

ts
definePattern: (def: PatternDef) => PatternDef

Typed help for writing a pattern

fileNormals beta ​

ts
export declare function fileNormals(pixels: Uint8Array): Uint8Array;

A normal map of a file (<texture>_n.png: x right, y up the picture, as most are drawn) made as heightNormals makes them, y down its rows, in place

GroundAdjust beta ​

ts
export interface GroundAdjust

How a ground's picture is changed as it is drawn (TileLook.adjust, MapTile.adjust): the file stays as it was. Each is nothing when left out

GroundLayerPixels beta ​

ts
export interface GroundLayerPixels

A layer of a ground as pixels (MapGroundLayer, made): its picture, size across, and how it is laid

GroundMix beta ​

ts
export interface GroundMix

How a ground mixed of two others is mixed (TileLook.mix, MapTile.mix): by a noise of its own, the second where the noise is high. Each as it is when left out

GroundPattern beta ​

ts
export type GroundPattern = 'grass' | 'dirt' | 'gravel' | 'sand' | 'rock' | 'snow' | 'plain' | 'cobbles' | 'cracked' | 'mud' | 'moss' | 'ice' | 'lava' | 'planks' | 'flagstones';

The client's own patterns, by name (PATTERNS): what a tile's texture made in code is a texture of, where a game names none of its own

GroundRecipe beta ​

ts
export interface GroundRecipe

What a ground made in code is made of besides its pattern and colour (TileLook.recipe, MapTile.pattern): each as the pattern has it when left out

groundTexture beta ​

ts
export declare function groundTexture(pattern: string | PatternDef | PatternMaker, color: Readonly<Rgb>, seed: number, size?: number, recipe?: GroundRecipe, patterns?: Readonly<Record<string, PatternDef>>): Uint8Array;

A texture of the ground, as RGBA bytes of size by size pixels, that repeats without a seam and is color on average. seed makes two tiles of the same pattern look apart (grass and dark grass). The pattern is one of the client's by name, a game's own by id (among patterns) or as it is (PatternDef), or pixels as a game makes them (PatternMaker); recipe is what else it is made of, its parameters among it

heightBlend beta ​

ts
export declare function heightBlend(heights: readonly number[], weights: readonly number[], depth?: number): number[];

How much of each of the tiles around a point shows, blended by height as the ground's shader does (GroundTilesPlugin): each tile's height there (0..1, its picture's alpha) raised by how near it is (weights, summing to 1); what is within depth of the highest shows, in proportion to how far over that line it is. Sums to 1. A small depth gives a crisp, ragged edge along the pictures' heights; a large one fades as the weights do

heightNormals beta ​

ts
export declare function heightNormals(pixels: Uint8Array, count: number, size: number, out?: Uint8Array, keep?: (layer: number) => boolean): Uint8Array;

The normals of pictures by their heights (their alpha, as the ground blends by: withHeight, PatternDef.height), as a normal map of each (RGBA, size across, count of them one after another as the ground's array has them): x along the picture's width, y down its rows and z out of it in red, green and blue (0..255 for -1..1, as normal maps are), alpha 255. Its slopes wrap round the edges, as the picture repeats. Into out where given (a layer's own map is kept where keep says)

keptParams beta ​

ts
export declare function keptParams(def: PatternDef, given?: Readonly<Record<string, number>>): Record<string, number> | undefined;

A pattern's parameters as they are kept (MapTile.pattern.params): those the pattern has that are not at their default, or nothing where none is

layered beta ​

ts
layered: (seed: number, periods: number[]) => (u: number, v: number) => number

Several noises, each finer and fainter than the one before: what looks like ground and not like a pattern. 0..1

layGround beta ​

ts
export declare function layGround(base: Uint8Array, layers: readonly GroundLayerPixels[], size?: number): Uint8Array;

A ground's picture with its layers laid over it, in order, as a new array (MapGroundLayer): each blended as it says, as much as it says, where its mask says. A layer that repeats more than once is sampled so (a whole number of times, so the ground still repeats without a seam)

mixPixels beta ​

ts
export declare function mixPixels(first: Uint8Array, second: Uint8Array, mix: GroundMix, size?: number): Uint8Array;

Two grounds' pixels (RGBA, size across) mixed into one, as a new array: the second in patches of a noise that repeats across the picture as they do, so the mix repeats without a seam too

opaque beta ​

ts
export declare function opaque(pixels: Uint8Array): Uint8Array;

A picture with no height and nothing see-through, in place: its alpha all 255. What a picture to show is made of a ground's pixels (their alpha is their height)

patchMask beta ​

ts
export declare function patchMask(mix: GroundMix, size?: number): Float32Array;

Patches of a noise that repeats across the picture, as a mix has them (GroundMix): how much of each pixel is in a patch, 0..1, as much of the picture as balance says, its edges as soft as softness. Kept once made: not to be changed

PatternDef beta ​

ts
export interface PatternDef

A pattern a ground's texture is made of in code (GameView.ground.patterns for a game's own, PATTERNS for the client's): what the Ground editor offers by name, with a slider for each of its parameters, and what groundTexture makes a texture of. Written as a shade, lighter or darker than the tile's colour at each point of the picture (about 1 on average: the texture is made the tile's colour exactly, whatever the shade does), from the parameters and a noise that repeats; or as every pixel, where a shade is not enough (several colours, a drawing)

patternDefs beta ​

ts
export declare function patternDefs(own?: Readonly<Record<string, PatternDef>>): {
    id: string;
    def: PatternDef;
}[];

The patterns there are to make a ground of, in the order they are offered: a game's own (GameView.ground.patterns) first, then the client's (PATTERNS), each by its id

PatternMaker beta ​

ts
export type PatternMaker = (size: number, color: Readonly<Rgb>, seed: number, params: Readonly<Record<string, number>>) => Uint8Array;

A pattern of a game's own as pixels alone (TileLook.pattern, PatternDef.pixels): the pixels of its texture, RGBA, size by size, in a colour, from a seed, its alpha its height (PatternDef.height). Cracked earth, hexagonal tiles, a painted sea

patternNamed beta ​

ts
export declare function patternNamed(pattern: string | PatternDef, own?: Readonly<Record<string, PatternDef>>): PatternDef;

A pattern by what names it: a definition as it is, one of the game's own by id (own), one of the client's by name, or the client's plain noise for a name there is not

patternNoise beta ​

ts
export declare function patternNoise(seed: number, fineness?: number): PatternNoise;

The noise a pattern is written with (PatternNoise), for a seed and a fineness: what groundTexture gives a pattern's shade, and what a game's pixels maker may take for itself

PatternNoise beta ​

ts
export interface PatternNoise

Noise to write a pattern with (PatternDef.shade): it repeats across the picture, so the texture has no seam; it is seeded from the pattern's seed, so two tiles of one pattern look apart (salt tells two noises of one pattern apart); and it is as fine or coarse as the recipe says (GroundRecipe.fineness)

PatternParamDef beta ​

ts
export interface PatternParamDef

A parameter of a pattern (PatternDef.params): a slider of the Ground editor, and a number in code (GroundRecipe.params, MapTile.pattern.params)

patternParams beta ​

ts
export declare function patternParams(def: PatternDef, given?: Readonly<Record<string, number>>): Record<string, number>;

A pattern's parameters as they are: each at its default where nothing is said

PATTERNS beta ​

ts
PATTERNS: Readonly<Record<GroundPattern, PatternDef>>

The client's patterns, by name (GroundPattern): grass, dirt, gravel, sand, rock, snow, plain, cobbles, cracked (cracked earth), mud, moss, ice, lava, planks and flagstones, each with the parameters its formula has. A game's own (GameView.ground.patterns) are offered before them; a game names one of these in a look (pattern: 'gravel') or a map's ground does (MapTile.pattern.kind)

RELIEF_SCALE beta ​

ts
RELIEF_SCALE: number

How steep a picture's height (its alpha, 0..1) is drawn as, across the picture: a slope of 1 is a rise of the whole height over a 32nd of the picture (an eighth of a cell, at four cells a picture). What heightNormals scales by

Seamless beta ​

ts
export type Seamless = 'blend' | 'mirror';

How a picture whose edges do not meet is made to repeat without a seam (TileLook.seamless): blend lays it shifted by half (where its edges meet) over its own edges, fading into it towards its middle, across and then down; mirror makes it half as large and mirrors it into four, which always meets and shows its symmetry

seamlessPixels beta ​

ts
export declare function seamlessPixels(pixels: Uint8Array, size: number, seamless: Seamless | undefined): Uint8Array;

A square picture's pixels (RGBA, size across) made to repeat without a seam, as a new array. As it was for none

TEXTURE_SIZE beta ​

ts
TEXTURE_SIZE = 256

The side of a texture, in pixels

TILE_PATTERNS beta ​

ts
TILE_PATTERNS: Readonly<Record<string, GroundPattern>>

The pattern of each of the tiles of the client's preset (TILE_LOOKS), by id

withHeight beta ​

ts
export declare function withHeight(pixels: Uint8Array, from?: Uint8Array): Uint8Array;

A picture's height written into its alpha, in place (RGBA, 0..255): how light from is at each pixel (a height picture of its own, TileLook.height, the same size), or the picture itself. What a file's height is: its light stones and tufts stand over its dark seams

WorleyPoint beta ​

ts
export interface WorleyPoint

What a cellular noise says of a point (PatternNoise.worley)