Gradient

References
public abstract class Gradient : IStorable
Base class for all Grasshopper gradients. Consider using GripGradient as a ready-made implementation.

Constructors

Gradient

#
Constructor.
protected Gradient()

Gradient

#
protected Gradient(
reader
)

Properties

ApparentDomain

#
Gets the domain based on the Mapping of this gradient. Note that this domain may be decreasing.
public (double lower, double upper) ApparentDomain { get; }

Interaction

#
Gets a user interaction object based on this gradient. Not all gradient types will have interaction objects.
public virtual GripGradientInteraction Interaction { get; }

IntrinsicDomain

#
Gets the interval containing the defined interior of this gradient. Note that this refers to the mathematics underlying the gradient, the ApparentDomain encodes the publicly facing domain of this gradient.
public abstract (double lower, double upper) IntrinsicDomain { get; }

Mapping

#
Gets the mapping from sampling space to gradient space.
public GradientMapping Mapping { get; }

Methods

ColourAt

#
Gets the exact colour at the given parameter.
public bool ColourAt(
parameter,
Evaluation parameter.
out Colour
colour
Colour result.
)
True if the parameter is a valid one.

ColourAt

#
Gets the colour at the given parameter.
public Color ColourAt(
parameter
Evaluation parameter.
)
True if the parameter is a valid one.

ColourAtInternal

#
Sample the gradient at the given gradient parameter.
protected abstract Colour ColourAtInternal(
gradientParameter
Parameter.
)
Colour at parameter or null if gradient is undefined.

CreateTextureCache

#
Create a texture cache object for displaying this texture in the UI. The width of the texture bitmap ought to be decided by the callee.
protected virtual Gradient.GradientTexture CreateTextureCache()

Draw

#
Draw this gradient as a horizontal progression. This method is optimized for speed and may not necessarily yield the exact result.
public virtual void Draw(
Graphics
graphics,
Graphics object to draw with.
RectangleF
rectangle,
Rectangle to fill.
lower,
Gradient parameter along left edge of rectangle.
upper
Gradient parameter along right edge of rectangle.
)

Draw

#
Draw this gradient as a horizontal progression. This method is optimized for speed and may not necessarily yield the exact result.
public void Draw(
Graphics
graphics,
Graphics object to draw with.
RectangleF
rectangle
Rectangle to fill.
)

FromColour

#
Create a standard gradient from black (0.0) to white (1.0) via colour. The colour grip is placed at its luminance equivalent within the gradient.
public static Gradient FromColour(
colour
Colour on the interior of the gradient.
)

FromSolidColour

#
Create a gradient with a single colour.
public static Gradient FromSolidColour(
colour
)

IsConstant

#
Tests whether this gradient has a zero-length domain and whether the colours on either side are identical.
public bool IsConstant(
out Colour
colour
Colour inside domain.
)
True if gradient only has a single colour.

Remap

#
Create a new gradient which is similar to this gradient but remapped to a different interval.
public Gradient Remap(
t0,
New gradient lower limit.
t1
New gradient upper limit.
)
Mapped gradient.

Remap

#
Create a new gradient which is similar to this gradient but remapped to a different interval.
public abstract Gradient Remap(
newMapping
)
Mapped gradient.

RemapAutomatic

#
Remap this gradient to a new domain if the mapping has automatic lower or upper bounds.
public Gradient RemapAutomatic(
lower,
upper
)

Store

#
Serialisation method.
public virtual void Store(
writer
)
Store

ToBitmap

#
Render this gradient to a bitmap using exact per-pixel colours.
public Bitmap ToBitmap(
width,
Bitmap width.
height,
Bitmap height.
lower,
Gradient parameter at left edge of bitmap.
upper
Gradient parameter at right edge of bitmap.
)
Bitmap.

ToBitmap

#
Render this gradient to a bitmap.
public Bitmap ToBitmap(
width,
Bitmap width.
height
Bitmap height.
)
Bitmap.

TryParse

#
Try and pase a gradient from text. This will both find standard and custom gradients by name, remapped standard or custom gradients and grip gradients defined from scratch.
public static Result<Gradient> TryParse(
text
)

WithAutomaticLimits

#
Adjust the automatic bounds flags for this gradient.
public Gradient WithAutomaticLimits(
autoLower = true,
autoUpper = true
)

Operators