@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
90 lines (89 loc) • 3.25 kB
TypeScript
/**
* NoiseGenerationUtilities
*
* Pure noise generation algorithms for procedural texture generation.
* This module provides the core algorithms without any rendering/output concerns.
*
* Used by TexturedRectangleGenerator to create Minecraft-style pixel art textures.
*/
import { IMcpColorRGBA, NoisePatternType } from "./IMcpModelDesign";
/**
* Parsed color with r, g, b, a components
*/
export interface ParsedColor {
r: number;
g: number;
b: number;
a: number;
}
/**
* Simple seeded pseudo-random number generator (Mulberry32).
* Produces deterministic sequences for consistent noise generation.
*/
export declare class SeededRandom {
private state;
constructor(seed: number);
/**
* Generate next random number in [0, 1)
*/
next(): number;
/**
* Generate random integer in [min, max] inclusive
*/
nextInt(min: number, max: number): number;
}
/**
* Noise generation utilities - pure algorithms for procedural noise patterns.
*/
export default class NoiseGenerationUtilities {
/**
* Hash function to generate seed from string (djb2 algorithm)
*/
static hashString(str: string): number;
/**
* Generate noise grid based on pattern type
*/
static generateNoiseGrid(pattern: NoisePatternType, colors: ParsedColor[], factor: number, width: number, height: number, rng: SeededRandom, scale: number): ParsedColor[][];
/**
* Simple random noise - each pixel randomly picks from colors
*/
static generateRandomGrid(colors: ParsedColor[], factor: number, width: number, height: number, rng: SeededRandom): ParsedColor[][];
/**
* Ordered dithering using Bayer matrix
*/
static generateDitherGrid(colors: ParsedColor[], factor: number, width: number, height: number): ParsedColor[][];
/**
* Perlin-like noise for organic variation
* Uses simplified value noise with interpolation and smooth color blending
*/
static generatePerlinGrid(colors: ParsedColor[], factor: number, width: number, height: number, rng: SeededRandom, scale: number): ParsedColor[][];
/**
* Bilinear interpolation for smooth noise
*/
static bilinearInterpolate(grid: number[][], x: number, y: number): number;
/**
* Stipple pattern - scattered dots on base color
*/
static generateStippleGrid(colors: ParsedColor[], factor: number, width: number, height: number, rng: SeededRandom): ParsedColor[][];
/**
* Gradient noise - smooth transition between colors
* Creates horizontal or vertical gradient with slight noise
*/
static generateGradientGrid(colors: ParsedColor[], width: number, height: number, rng: SeededRandom): ParsedColor[][];
/**
* Linear interpolation between two colors
*/
static lerpColor(c1: ParsedColor, c2: ParsedColor, t: number): ParsedColor;
/**
* Check if two colors are equal
*/
static colorsEqual(c1: ParsedColor, c2: ParsedColor): boolean;
/**
* Convert parsed color to hex string
*/
static colorToHex(color: ParsedColor): string;
/**
* Parse color input (string or RGBA object) to ParsedColor
*/
static parseColorInput(input: string | IMcpColorRGBA): ParsedColor;
}