ColorRamp

Description

sealed class Tinman.Terrain.Util.ColorRamp

Derived from

ColorRampBase abstract

This class represents a color ramp that interpolates between defined slots.

A color ramp consists of zero or more color ramp slots, where the slots hold monotonically increasing coordinates with their respective color value. To create a color ramp, do this:

  • Use Color1 or Color2 for the trivial cases of one or two colors.

  • Otherwise, create a ColorRamp object, optionally passing in an initial capacity.

  • Use Add or Set to add slots to the color ramp. The latter can also be used to updated existing slots.

  • Use Count, ColorAt and CoordinateAt to query the slots.

Public / Constants

Earth


[ShutdownSurvive]
public static readonly attribute Earth → (IColorRamp)

A color ramp for Earth with intuitive colors.

Use ellipsoid/geoid heights as input for the color ramp: -1000m .. 8000m.

Mars


[ShutdownSurvive]
public static readonly attribute Mars → (IColorRamp)

A rainbow color ramp for Mars.

Use areoid heights as input for the color ramp: -7500m .. 15000m.

Mask


[ShutdownSurvive]
public static readonly attribute Mask → (IColorRamp)

A simple mask shape.

To create an equivalent color ramp, call Shape, passing 0 to the first parameter and the default values to the remaining ones.

Moon


[ShutdownSurvive]
public static readonly attribute Moon → (IColorRamp)

A rainbow color ramp for the Moon.

Use reference sphere heights as input for the color ramp: -9000m .. 10000m.

Outline


[ShutdownSurvive]
public static readonly attribute Outline → (IColorRamp)

A simple outline shape.

To create an equivalent color ramp, call Shape, the default parameter values.

Planet


[ShutdownSurvive]
public static readonly attribute Planet → (IColorRamp)

A rainbow color ramp for a planet.

Use normalized heights as input for the color ramp: -1 .. +1.

Pluto


[ShutdownSurvive]
public static readonly attribute Pluto → (IColorRamp)

A rainbow color ramp for Pluto.

Use reference sphere heights as input for the color ramp: -3000m .. 4000m.

Public / Constructors

Color

2 overloads


public static method Color1 → (1)

color in : int64

The color ramp color.

returns → IColorRamp

The created ColorRamp.

Creates a color ramp with a single color.

The color is placed at the X-coordinate 0.0.


public static method Color2 → (4)

colorA in : int64

The first color ramp color.

colorB in : int64

The second color ramp color.

coordA opt : float64 = 0

Coordinate of colorA in.

coordB opt : float64 = 1

Coordinate of colorB in.

returns → IColorRamp

The created ColorRamp.

Creates a color ramp with two colors.

Color​Ramp

2 overloads


public constructor ColorRamp1 → ()

Creates a new instance of ColorRamp.


public constructor ColorRamp2 → (1)

initialCapacity in : int32

[>=0]
The initial capacity of the color ramp.

Creates a new instance of ColorRamp.

Rainbow


public static method Rainbow → (2)

minimum in : float64

The minimum input value of the color ramp. Will be mapped to violet/blue.

maximum in : float64

The maximum input value of the color ramp. Will be mapped to red/white.

returns → IColorRamp

The rainbow color ramp.

Creates a rainbow-like color ramp.

Shape


public static method Shape → (4)

thickness opt : float64 = 1

[>=0]
The thickness of the shape border. Set to 0 to remove the border.

border opt : int64 = Colors.Black & Colors.Opaque25

The color of the shape border. Set alpha to 0 to hide the border.

fill opt : int64 = Colors.White

The fill color of the shape interior. Set alpha to 0 to hide the interior fill.

epsilon opt : float64 = 1E-5

The small offset to use for the innermost and outermost colors of the ramp.

returns → IColorRamp

The created ColorRamp.

Creates a color ramp for drawing the interior and/or border of a shape.

Here are some common usage scenarios for this method:

  • ColorRamp.Shape()
    Draw the shape with a single pixel black border and white fill (good for debug / test).

  • ColorRamp.Shape(0)
    Draw the shape without border and white fill (good for modulation / clip masks).

  • ColorRamp.Shape(0,0,fill)
    Draw the shape without border and the given fill color.

  • ColorRamp.Shape(thickness,border,0)
    Draw the shape with a border of the given thickness and color, without fill.

The returned color ramps contains four colors:

 X      | Y
--------+--------
 -h - e | fill
 -h     | border
 +h     | border
 +h + e | empty

where h is half of thickness opt, e is epsilon opt and empty is the same color as border opt (or fill opt if thickness opt is zero) with its alpha channel set to zero.

Vertical


public static method Vertical → (2)

range in : VerticalRange

The vertical range, in the given unit opt.

unit opt : UnitOfMeasure = null

The vertical unit. If null, UnitOfMeasure.Metre is used.

returns → IColorRamp

The default color ramp, using vertical coordinates in unit opt as input.

Returns a default color ramp for the given vertical range.

Public / Methods

Add


public method Add → (2)

coordinate in : float64

Coordinate of color ramp slot.

color in : int64

Color value of color ramp slot (see Colors).

returns → ColorRamp

this

Adds a color on this color ramp.

The color ramp slots must be set so that the following condition is met:

x[i] >= x[i-1]

The X-coordinate of a color ramp slot must be greater than or equal to the X-coordinate of the preceding slot.

Color​At


[Pure]
public method ColorAt → (1)

index in : int32

[0..ColorRamp.Count-1]
The color ramp slot index.

returns → int64

The color value.

Returns the color value of the given slot.

Coordinate​At


[Pure]
public method CoordinateAt → (1)

index in : int32

[0..ColorRamp.Count-1]
The color ramp slot index.

returns → float64

The coordinate value.

Returns the coordinate of the given slot.

Index


[Pure]
public method Index → (1)

in : float64

Coordinate of color to return.

returns → float64

The color index. Will be 0 if Count is zero.

Returns a color index on this color ramp.

Set


public method Set → (3)

idx in : int32

[0..ColorRamp.Count]
Index of color ramp slot.

coordinate in : float64

Coordinate of color ramp slot.

color in : int64

Color value of color ramp slot (see Colors).

returns → ColorRamp

this

Sets a color on this color ramp.

The color ramp slots must be set so that the following condition is met:

x[i] >= x[i-1]

The X-coordinate of a color ramp slot must be greater than or equal to the X-coordinate of the preceding slot.

Public / Attributes

Count


public attribute Count → (get)

value : int32

[>=0]
The number of color ramp slots.

Returns the number of color ramp slots.

Configuration

Config


public static attribute Config → (get)

value : IConfigurator<IColorRamp>

[not-null]
The configurator object.

The configurator object for this type.

Serialization

Serial​Id


public static readonly attribute SerialId → (ISerialTypeInfo)

Serialization information about this type.