GH_Gradient

References
public class GH_Gradient : GH_ISerializable, IGradient
Represents a colour gradient defined by a succession of grips.

Constructors

GH_Gradient

#
public GH_Gradient()

GH_Gradient

#
public GH_Gradient(GH_Gradient other)
Create a duplicate of another gradient.
other (GH_Gradient)Gradient to duplicate.

GH_Gradient

#
public GH_Gradient(IEnumerable<double> parameters, IEnumerable<Color> colours)
Create a new gradient from grips and colours.
parameters (IEnumerable<double>)Grip locations.
colours (IEnumerable<Color>)Colours for each grip.

Properties

GripCount

#
public int GripCount { get; }
Gets the number of grips in this gradient.

Linear

#
public bool Linear { get; set; }
Gets or sets whether the colours are interpolated linearly between grips.

Locked

#
public bool Locked { get; set; }
Gets or sets whether this gradient is locked. A locked gradient cannot be modified by the user.

SelectedGrip

#
public GH_Grip SelectedGrip { get; set; }
Gets or sets the selected grip.

Indexers

Grip

#
public GH_Grip this[int index] { get; set; }
Gets or sets the grip at the given index.
index (int)Index of grip to retrieve.
The grip at the given index.

Methods

Explicit

IGradient.AddCurrentAsPreset

#
void AddCurrentAsPreset()
Adds a copy of this gradient to the shared Grasshopper preset collection.

AddGrip

#
public GH_Grip AddGrip(double t, Color c)
Add a new single-colour grip.
t (double)Parameter for grip.
c (Color)Colour of grip.

AddGrip

#
public GH_Grip AddGrip(double t, Color c0, Color c1)
Add a new bi-colour grip.
t (double)Parameter for grip.
c0 (Color)Left colour of grip.
c1 (Color)Right colour of grip.

AddGrip

#
public GH_Grip AddGrip(double t)
Add a new grip to the gradient. The colour of the grip will be picked so that there is no difference to the gradient, though this is not actually possible when the interpolation mode is not linear.
t (double)Grip parameter.

AddGrip

#
public void AddGrip(GH_Grip grip)
Add a new grip to the gradient. This method does not raise the GradientChanged event, so you need to do that yourself by calling OnGradientChanged().
grip (GH_Grip)Grip to add.

ColourAt

#
public Color ColourAt(double t)
Evaluate the colour at a specific parameter.
t (double)Parameter to evaluate.
The colour at the given parameter.

DeleteGripRegion

#
public static RectangleF DeleteGripRegion(RectangleF destination)
Gets the Delete Grip region rectangle based on a gradient destination rectangle.
destination (RectangleF)Gradient destination rectangle.
Explicit

IGradient.DeletePreset

#
void DeletePreset(int index)
Removes the preset at the given index from the shared Grasshopper preset collection.
index (int)

DisplayGradientEditor

#
public void DisplayGradientEditor()

DisplayGripColourPicker

#
public void DisplayGripColourPicker(GH_Grip grip)
grip (GH_Grip)
Explicit

IGradient.DrawToGraphics

#
void DrawToGraphics(Graphics g, RectangleF dest)
g (Graphics)
dest (RectangleF)

EarthlyBrown

#
public static GH_Gradient EarthlyBrown()

Forest

#
public static GH_Gradient Forest()
Explicit

IGradient.GetColorStops

#
ColorStop[] GetColorStops()
Explicit

IGradient.GetPresets

#
ColorStop[][] GetPresets()
Returns the shared Grasshopper gradient presets as color stop collections. Reads the same [grasshopper_gradients] settings database used by the Gradient component.

GreyScale

#
public static GH_Gradient GreyScale()

Heat

#
public static GH_Gradient Heat()

MouseDown

#
public bool MouseDown(RectangleF dest, PointF pt)
Begin grip drag operation.
dest (RectangleF)Destination rectangle of the gradient.
pt (PointF)Mouse position in destination coordinates.
True if a grip drag was started, false otherwise.

MouseDragAbort

#
public bool MouseDragAbort()
Abort grip drag.

MouseMove

#
public bool MouseMove(RectangleF dest, PointF pt)
Continue grip dragging operation.
dest (RectangleF)Destination rectangle of gradient.
pt (PointF)Mouse position in destination coordinates.
True if a grip position was changed, false otherwise. Redraws are only required on TRUE.

MouseUp

#
public bool MouseUp(RectangleF dest, PointF pt, bool deselect)
Terminate grip drag.
dest (RectangleF)Destination rectangle of gradient
pt (PointF)Mouse location in destination coordinates
deselect (bool)

NearestGrip

#
public int NearestGrip(double t, GH_GripSide side)
Find the nearest grip to a parameter.
t (double)Parameter to search from.
side (GH_GripSide)Side to search.
The grip nearest to the parameter.

NearestGrip

#
public int NearestGrip(double t)
Find the nearest grip to a parameter.
t (double)Parameter to search from.
The grip nearest to the parameter.

NearestGrip

#
public int NearestGrip(RectangleF dest, PointF pt, double maxRadius)
Find the nearest grip in screen coordinates.
dest (RectangleF)Retangle that contains the entire gradient.
pt (PointF)Point to search from.
maxRadius (double)Maximum distance between point and grip.
The grip closest to the point.

NewGripRegion

#
public static RectangleF NewGripRegion(RectangleF destination)
Gets the new Grip region rectangle based on a gradient destination rectangle.
destination (RectangleF)Gradient destination rectangle.

NormalizeGrips

#
public void NormalizeGrips()
Normalize all grips. This will scale all grip parameters so that the full gradient extend equals 0~1.

OnGradientChanged

#
public void OnGradientChanged()
Raise the GradientChanged event.

OnGradientChangedIntermediate

#
public void OnGradientChangedIntermediate()
Raise the GradientChanged event.

OnSelectionChanged

#
public void OnSelectionChanged()
Raise the SelectionChanged event.

Read

#
public bool Read(GH_IReader reader)
reader (GH_IReader)
Read

RemoveGrip

#
public void RemoveGrip(GH_Grip grip)
Remove the specified grip.
grip (GH_Grip)Grip to remove.

RemoveGrip

#
public void RemoveGrip(int index)
Remove the grip at the specified index.
index (int)Index of grip to remove.

Render_Background

#
public void Render_Background(Graphics g, RectangleF dest)
g (Graphics)
dest (RectangleF)

Render_Gradient

#
public void Render_Gradient(Graphics g, RectangleF dest)
g (Graphics)
dest (RectangleF)

Render_Grips

#
public void Render_Grips(Graphics g, RectangleF dest)
g (Graphics)
dest (RectangleF)
Explicit

IGradient.RhinoUiMouseDown

#
bool RhinoUiMouseDown(RectangleF dest, PointF pt)
dest (RectangleF)
pt (PointF)
Explicit

IGradient.SetColorStops

#
void SetColorStops(IEnumerable<ColorStop> stops)
stops (IEnumerable<ColorStop>)
Explicit

IGradient.SetDefault

#
void SetDefault(IEnumerable<ColorStop> stops)
Stores the given color stops as the shared Grasshopper default gradient.
stops (IEnumerable<ColorStop>)

SoGay

#
public static GH_Gradient SoGay()

Spectrum

#
public static GH_Gradient Spectrum()

Traffic

#
public static GH_Gradient Traffic()

Write

#
public bool Write(GH_IWriter writer)
writer (GH_IWriter)
Write

Zebra

#
public static GH_Gradient Zebra()

Events

GradientChanged

#
public event GH_Gradient.GradientChangedEventHandler GradientChanged
Explicit

IGradient.RhinoUiGradientChanged

#
event EventHandler RhinoUiGradientChanged
Explicit

IGradient.RhinoUiSelectionChanged

#
event EventHandler RhinoUiSelectionChanged

SelectionChanged

#
public event GH_Gradient.SelectionChangedEventHandler SelectionChanged