Class NoiseFunctions

java.lang.Object
swingtree.style.NoiseFunctions

public final class NoiseFunctions extends Object
A collection of noise functions that can be used to generate procedural textures. The functions in this class are also supposed to serve as an example which demonstrates how to create procedural textures yourself.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    bricks(float xIn, float yIn)
    A brick wall in running bond, every course offset by half a brick.
    static float
    brushedMetal(float xIn, float yIn)
    Finely brushed metal: streaks stretched far along the horizontal axis at three different frequencies, under a broad, soft sheen.
    static float
    bubbles(float xIn, float yIn)
    Soap foam: overlapping bubbles of differing size, each domed by its own curvature and outlined by a bright film at the rim.
    static float
    camouflage(float xIn, float yIn)
    A four tone camouflage pattern: irregular patches with torn, interlocking edges, quantised into flat bands of colour.
    static float
    caustics(float xIn, float yIn)
    The rippling net of light cast on the floor of a swimming pool: two overlaid webs of bright cell edges, brightest where they meet.
    static float
    cells(float xIn, float yIn)
     
    static float
    circuit(float xIn, float yIn)
    A printed circuit board: right angled and quarter turn traces running between occasional ring shaped solder pads.
    static float
    clouds(float xIn, float yIn)
    Soft, billowing clouds produced by fractal Brownian motion and a sigmoid contrast curve which crisps the cloud edges up against the open sky.
    static float
    concrete(float xIn, float yIn)
    Poured concrete: broad cement mottling, a fine sandy grit and scattered air pockets whose positions are pushed off their lattice so they do not fall into rows.
    static float
    cracks(float xIn, float yIn)
    A network of thin cracks separating irregular plates, computed from the difference between the two closest Worley (Voronoi) feature points.
    static float
    denim(float xIn, float yIn)
    Denim: the diagonal ribs of a twill weave, crossed by warp and weft threads, with slubs in the yarn and gentle fading across the cloth.
    static float
    fabric(float xIn, float yIn)
     
    static float
    flow(float xIn, float yIn)
    A fluid, organic flow field produced by "domain warping": fractal noise is sampled at coordinates that are themselves displaced by other fractal noise.
    static float
    foliage(float xIn, float yIn)
    A leafy foliage texture.
    static float
    fractal(float xIn, float yIn)
    Plain fractal Brownian motion: several octaves of value noise summed with halving amplitude.
    static float
    frost(float xIn, float yIn)
    Ice crystals creeping across a cold window: jagged, feathery veins branching out between fern like fronds, over a finely frosted surface.
    static float
    gemStones(float xIn, float yIn)
     
    static float
    grainy(float xIn, float yIn)
     
    static float
    halftone(float xIn, float yIn)
    A print halftone screen: a grid of dots on the classic 45 degree angle, whose size follows an underlying tone.
    static float
    hardSpots(float xIn, float yIn)
     
    static float
    hardTopology(float xIn, float yIn)
     
    static float
    haze(float xIn, float yIn)
     
    static float
    herringbone(float xIn, float yIn)
    Herringbone parquet: planks laid at right angles in a zig zag, each with its own tone and a grain running along its length.
    static float
    honeycomb(float xIn, float yIn)
    A honeycomb of tight packed hexagonal cells, each shaded like a shallow dome and separated by dark walls.
    static float
    leather(float xIn, float yIn)
    Full grain leather: a network of soft creases enclosing rounded pebbles, with a fine grain over the top.
    static float
    lightning(float xIn, float yIn)
    Crackling electric arcs.
    static float
    mandelbrot(float xIn, float yIn)
     
    static float
    marble(float xIn, float yIn)
    A turbulent marble texture: a regular striped pattern is distorted by several octaves of value noise, bending the stripes into organic, swirling veins.
    static float
    mosaic(float xIn, float yIn)
     
    static float
    paper(float xIn, float yIn)
    Uncoated paper: crossed short fibres, scattered flecks and a faint unevenness in the pulp.
    static float
    plasma(float xIn, float yIn)
    A smooth, flowing interference pattern built from a handful of summed sine waves - the classic "plasma" demo effect, great for vivid color gradients.
    static float
    pondInDrizzle(float xIn, float yIn)
     
    static float
    pondInRain(float xIn, float yIn)
     
    static float
    pondOfStrings(float xIn, float yIn)
     
    static float
    pondOfTangledStrings(float xIn, float yIn)
     
    static float
    retro(float xIn, float yIn)
     
    static float
    ridges(float xIn, float yIn)
    A branching network of sharp crests separated by smooth valleys, the way a mountain range looks from above.
    static float
    sand(float xIn, float yIn)
    Wind blown sand: long ripples curving with the wind direction, over a fine grain and slow rises and dips of the dunes underneath.
    static float
    scales(float xIn, float yIn)
    Overlapping scales in offset rows, each row laid over the one behind it.
    static float
    scratches(float xIn, float yIn)
    A worn metal surface, scuffed by sparse straight scratches running at several angles.
    static float
    smoke(float xIn, float yIn)
    A column of smoke drifting upward, stretched along the vertical axis and sheared sideways so the plume curls as it rises.
    static float
    smoothSpots(float xIn, float yIn)
     
    static float
    smoothTopology(float xIn, float yIn)
    Undulating hills and valleys: the stochastic field is modulated with multiple sine waves to create smooth, flowing topology with natural ridges and crests.
    static float
    spirals(float xIn, float yIn)
     
    static float
    stars(float xIn, float yIn)
    A field of stars, each with a bright core and a soft halo, scattered over a faint nebula.
    static float
    stochastic(float xIn, float yIn)
    Stochastic pseudorandom grain produced by summing randomly sampled gradients within a neighborhood, then squashing the result through a sine wave for a characteristic speckled look.
    static float
    tiles(float xIn, float yIn)
     
    static float
    tissue(float xIn, float yIn)
     
    static float
    turbulence(float xIn, float yIn)
    Wispy, veined noise, made by creasing the noise field at every zero crossing instead of rounding it off.
    static float
    vortex(float xIn, float yIn)
    A swirling vortex created by rotating the sampling angle as a function of the radius and an underlying fractal noise field.
    static float
    waves(float xIn, float yIn)
    An open water swell: long parallel crests, gently meandering, each breaking into a thin line of foam at its peak.
    static float
    weave(float xIn, float yIn)
    Plain woven cloth: strands passing over and under one another, rounded across their width, shaded where they dip below the crossing strand.
    static float
    wood(float xIn, float yIn)
    Concentric, slightly distorted growth rings reminiscent of a cross-cut piece of timber.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • stochastic

      public static float stochastic(float xIn, float yIn)
      Stochastic pseudorandom grain produced by summing randomly sampled gradients within a neighborhood, then squashing the result through a sine wave for a characteristic speckled look.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the stochastic grain intensity at the given location.
    • smoothTopology

      public static float smoothTopology(float xIn, float yIn)
      Undulating hills and valleys: the stochastic field is modulated with multiple sine waves to create smooth, flowing topology with natural ridges and crests.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the terrain topology height at the given location.
    • hardTopology

      public static float hardTopology(float xIn, float yIn)
    • hardSpots

      public static float hardSpots(float xIn, float yIn)
    • smoothSpots

      public static float smoothSpots(float xIn, float yIn)
    • grainy

      public static float grainy(float xIn, float yIn)
    • tiles

      public static float tiles(float xIn, float yIn)
    • fabric

      public static float fabric(float xIn, float yIn)
    • retro

      public static float retro(float xIn, float yIn)
    • cells

      public static float cells(float xIn, float yIn)
    • haze

      public static float haze(float xIn, float yIn)
    • spirals

      public static float spirals(float xIn, float yIn)
    • mandelbrot

      public static float mandelbrot(float xIn, float yIn)
    • tissue

      public static float tissue(float xIn, float yIn)
    • mosaic

      public static float mosaic(float xIn, float yIn)
    • gemStones

      public static float gemStones(float xIn, float yIn)
    • pondInDrizzle

      public static float pondInDrizzle(float xIn, float yIn)
    • pondInRain

      public static float pondInRain(float xIn, float yIn)
    • pondOfStrings

      public static float pondOfStrings(float xIn, float yIn)
    • pondOfTangledStrings

      public static float pondOfTangledStrings(float xIn, float yIn)
    • marble

      public static float marble(float xIn, float yIn)
      A turbulent marble texture: a regular striped pattern is distorted by several octaves of value noise, bending the stripes into organic, swirling veins.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the marble texture intensity at the given location.
    • wood

      public static float wood(float xIn, float yIn)
      Concentric, slightly distorted growth rings reminiscent of a cross-cut piece of timber. The rings are warped by fractal noise to give them a natural grain.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the wood grain intensity at the given location.
    • plasma

      public static float plasma(float xIn, float yIn)
      A smooth, flowing interference pattern built from a handful of summed sine waves - the classic "plasma" demo effect, great for vivid color gradients.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the plasma intensity at the given location.
    • clouds

      public static float clouds(float xIn, float yIn)
      Soft, billowing clouds produced by fractal Brownian motion and a sigmoid contrast curve which crisps the cloud edges up against the open sky.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the cloud density at the given location.
    • cracks

      public static float cracks(float xIn, float yIn)
      A network of thin cracks separating irregular plates, computed from the difference between the two closest Worley (Voronoi) feature points.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the crack pattern intensity at the given location.
    • vortex

      public static float vortex(float xIn, float yIn)
      A swirling vortex created by rotating the sampling angle as a function of the radius and an underlying fractal noise field.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the vortex intensity at the given location.
    • flow

      public static float flow(float xIn, float yIn)
      A fluid, organic flow field produced by "domain warping": fractal noise is sampled at coordinates that are themselves displaced by other fractal noise.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the flow field intensity at the given location.
    • lightning

      public static float lightning(float xIn, float yIn)
      Crackling electric arcs. A fractal noise field is traced along the contour where it crosses its mid value - that contour naturally branches and loops - while a jagged domain warp makes the arcs zig-zag like a real discharge.

      The contour is rendered as a uniformly thin bolt by dividing the distance to the mid value by the local gradient: |field - 0.5| / |gradient| is an estimate of the true distance to the contour, so the bolt keeps the same width regardless of how steep the field is (no fat blobs on flat spots).

      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the lightning bolt intensity at the given location.
    • foliage

      public static float foliage(float xIn, float yIn)
      A leafy foliage texture. Leaves are scattered from a jittered grid - jittered far enough that the underlying grid disappears - and layered by a random depth so they overlap naturally. To avoid a sterile, too-perfect look, every leaf is individually irregular: its spine bends like a banana, its outline is asymmetric (rounded toward the base, drawn to a point at the tip) with a wavy edge, and its surface is broken up by value-noise mottling. Each leaf carries a lit midrib and faint herringbone side veins, and leaves further back are shaded darker for depth.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the foliage texture intensity at the given location.
    • fractal

      public static float fractal(float xIn, float yIn)
      Plain fractal Brownian motion: several octaves of value noise summed with halving amplitude. The neutral, all purpose cloud field other looks are built from, and the one to reach for when a background just needs to stop being flat.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the fractal noise intensity at the given location.
    • turbulence

      public static float turbulence(float xIn, float yIn)
      Wispy, veined noise, made by creasing the noise field at every zero crossing instead of rounding it off. Reads as smoke, steam or weathered stone.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the turbulent noise intensity at the given location.
    • ridges

      public static float ridges(float xIn, float yIn)
      A branching network of sharp crests separated by smooth valleys, the way a mountain range looks from above. The opposite character to clouds(float, float).
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the ridge pattern intensity at the given location.
    • brushedMetal

      public static float brushedMetal(float xIn, float yIn)
      Finely brushed metal: streaks stretched far along the horizontal axis at three different frequencies, under a broad, soft sheen.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the brushed metal texture intensity at the given location.
    • scratches

      public static float scratches(float xIn, float yIn)
      A worn metal surface, scuffed by sparse straight scratches running at several angles. Each scratch fades in and out along its length instead of crossing the whole surface.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the scratch pattern intensity at the given location.
    • concrete

      public static float concrete(float xIn, float yIn)
      Poured concrete: broad cement mottling, a fine sandy grit and scattered air pockets whose positions are pushed off their lattice so they do not fall into rows.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the concrete texture intensity at the given location.
    • paper

      public static float paper(float xIn, float yIn)
      Uncoated paper: crossed short fibres, scattered flecks and a faint unevenness in the pulp. Subtle enough to sit under text.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the paper texture intensity at the given location.
    • sand

      public static float sand(float xIn, float yIn)
      Wind blown sand: long ripples curving with the wind direction, over a fine grain and slow rises and dips of the dunes underneath.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the sand texture intensity at the given location.
    • leather

      public static float leather(float xIn, float yIn)
      Full grain leather: a network of soft creases enclosing rounded pebbles, with a fine grain over the top.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the leather texture intensity at the given location.
    • denim

      public static float denim(float xIn, float yIn)
      Denim: the diagonal ribs of a twill weave, crossed by warp and weft threads, with slubs in the yarn and gentle fading across the cloth.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the denim texture intensity at the given location.
    • bricks

      public static float bricks(float xIn, float yIn)
      A brick wall in running bond, every course offset by half a brick. Each brick carries its own fired tone and the mortar joints sit between them.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the brick texture intensity at the given location.
    • herringbone

      public static float herringbone(float xIn, float yIn)
      Herringbone parquet: planks laid at right angles in a zig zag, each with its own tone and a grain running along its length.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the herringbone texture intensity at the given location.
    • honeycomb

      public static float honeycomb(float xIn, float yIn)
      A honeycomb of tight packed hexagonal cells, each shaded like a shallow dome and separated by dark walls.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the honeycomb texture intensity at the given location.
    • weave

      public static float weave(float xIn, float yIn)
      Plain woven cloth: strands passing over and under one another, rounded across their width, shaded where they dip below the crossing strand.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the weave texture intensity at the given location.
    • halftone

      public static float halftone(float xIn, float yIn)
      A print halftone screen: a grid of dots on the classic 45 degree angle, whose size follows an underlying tone. The look of newsprint and comic shading.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the halftone dot intensity at the given location.
    • scales

      public static float scales(float xIn, float yIn)
      Overlapping scales in offset rows, each row laid over the one behind it. Reads as fish or reptile skin, or as a roof of shingles.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the scale texture intensity at the given location.
    • circuit

      public static float circuit(float xIn, float yIn)
      A printed circuit board: right angled and quarter turn traces running between occasional ring shaped solder pads.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the circuit board texture intensity at the given location.
    • bubbles

      public static float bubbles(float xIn, float yIn)
      Soap foam: overlapping bubbles of differing size, each domed by its own curvature and outlined by a bright film at the rim.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the bubble foam texture intensity at the given location.
    • camouflage

      public static float camouflage(float xIn, float yIn)
      A four tone camouflage pattern: irregular patches with torn, interlocking edges, quantised into flat bands of colour.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the camouflage pattern intensity at the given location.
    • caustics

      public static float caustics(float xIn, float yIn)
      The rippling net of light cast on the floor of a swimming pool: two overlaid webs of bright cell edges, brightest where they meet.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the caustics pattern intensity at the given location.
    • frost

      public static float frost(float xIn, float yIn)
      Ice crystals creeping across a cold window: jagged, feathery veins branching out between fern like fronds, over a finely frosted surface.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the frost crystal intensity at the given location.
    • smoke

      public static float smoke(float xIn, float yIn)
      A column of smoke drifting upward, stretched along the vertical axis and sheared sideways so the plume curls as it rises.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the smoke density at the given location.
    • stars

      public static float stars(float xIn, float yIn)
      A field of stars, each with a bright core and a soft halo, scattered over a faint nebula. Made for dark backgrounds.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the star field brightness at the given location.
    • waves

      public static float waves(float xIn, float yIn)
      An open water swell: long parallel crests, gently meandering, each breaking into a thin line of foam at its peak.
      Parameters:
      xIn - The x coordinate in translated, scaled and rotated virtual space.
      yIn - The y coordinate in translated, scaled and rotated virtual space.
      Returns:
      A float in the range [0, 1] representing the water wave intensity at the given location.