GH_Capsule

References
public class GH_Capsule : IDisposable
Class used to draw standard Grasshopper interface boxes.

Fields

DefaultHighlight

#
The default size (in pixel units) of the highlight bar.
public const int DefaultHighlight = 8

DefaultRadius

#
The default radius (in pixel units) of the rounded corners.
public const int DefaultRadius = 3

Properties

Box

#
Gets the outline box for this Capsule.
public Rectangle Box { get; }

Box_Content

#
Gets the content box for this Capsule. Text and icons are drawn inside this box.
public Rectangle Box_Content { get; }

Font

#
Gets or sets the Font to use for text rendering.
public Font Font { get; set; }

Highlight

#
Gets the highlight size for this Capsule. Zero or negative means there is no highlight.
public int Highlight { get; }

HighlightShape

#
Gets the graphics path that describes the highlight bar shape of the capsule.
public GraphicsPath HighlightShape { get; }

InputGrips

#
Gets the list of locally defined input grip locations.
public List<Point> InputGrips { get; }

JaggedLeft

#
Gets whether the left edge of this capsule is jagged.
public bool JaggedLeft { get; }

JaggedRight

#
Gets whether the right edge of this capsule is jagged.
public bool JaggedRight { get; }

MaxRadius

#
Gets the largest radius defined for this capsule.
public int MaxRadius { get; }

OutlineShape

#
Gets the graphics path that describes the outer edge of the capsule.
public GraphicsPath OutlineShape { get; }

OutputGrips

#
Gets the list of locally defined output grip locations.
public List<Point> OutputGrips { get; }

Palette

#
Gets or sets the palette for this Capsule.
public GH_Palette Palette { get; set; }

Radius

#
Gets the radius of the rounded corners of this Capsule.
public int Radius[int index] { get; }
index (int)Corner index.

0 = upper left

1 = upper right

2 = lower right

3 = lower left

RenderEngine

#
Gets the RenderEngine associated with this capsule. You typically don't need to go this far, just use one of the Render() overloads on GH_Capsule directly.
public GH_CapsuleRenderEngine RenderEngine { get; }
Remarks: Do not store pointers to the RenderEngine, always call this property anew.

Text

#
Gets or sets the text to render in the content box.
public string Text { get; set; }

TextOrientation

#
Gets or sets the orientation of the text within the content box.
public GH_Orientation TextOrientation { get; set; }

Methods

AddInputGrip

#
Add an input grip to this UI Box.
public void AddInputGrip(
X,
X coordinate of grip.
Y
Y coordinate of grip.
)

AddInputGrip

#
Add an input grip to this UI Box. This is the recommended overload.
public void AddInputGrip(
Y
Y coordinate of grip.
)

AddInputGrip

#
Add an input grip to this UI Box.
public void AddInputGrip(
Point
P
Coordinate of grip.
)

AddInputGrip

#
Add an input grip to this UI Box.
public void AddInputGrip(
PointF
P
Coordinate of grip.
)

AddOutputGrip

#
Add an output grip to this UI Box.
public void AddOutputGrip(
X,
X coordinate of grip.
Y
Y coordinate of grip.
)

AddOutputGrip

#
Add an output grip to this UI Box. This is the recommended overload.
public void AddOutputGrip(
Y
Y coordinate of grip.
)

AddOutputGrip

#
Add an output grip to this UI Box.
public void AddOutputGrip(
Point
P
Coordinate of grip.
)

AddOutputGrip

#
Add an output grip to this UI Box.
public void AddOutputGrip(
PointF
P
Coordinate of grip.
)

Contains

#
Test a point for capsule containment.
public bool Contains(
PointF
pt
Point to test.
)
True if the point is on the interior of the capsule.

CreateCapsule

#
Create a new blank capsule.
public static GH_Capsule CreateCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette,
Colour palette to apply.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
Create a new blank capsule.
public static GH_Capsule CreateCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette,
Colour palette to apply.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
Create a new blank capsule with default radius and highlight dimensions.
public static GH_Capsule CreateCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette
Colour palette to apply.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
Create a new blank capsule.
public static GH_Capsule CreateCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette,
Colour palette to apply.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
Create a new blank capsule.
public static GH_Capsule CreateCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette,
Colour palette to apply.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
Create a new blank capsule with default radius and highlight dimensions.
public static GH_Capsule CreateCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette
Colour palette to apply.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
orientation,
Orientation of text within box.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
orientation,
Orientation of text within box.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
orientation
Orientation of text within box.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font
Font to draw text with.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
Rectangle
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
Rectangle
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text
Text to display inside the capsule.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
orientation,
Orientation of text within box.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
orientation,
Orientation of text within box.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
orientation
Orientation of text within box.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font,
Font to draw text with.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
Font
font
Font to draw text with.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
radius,
Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text,
Text to display inside the capsule.
int[]
radii,
Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight
Height of the highlight bar. A value of zero or lower disables the highlight.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
Create a new capsule with content text.
public static GH_Capsule CreateTextCapsule(
box,
Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox,
Box into which the text will be drawn.
palette,
Colour palette to apply.
text
Text to display inside the capsule.
)
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

Dispose

#
public void Dispose()

Dispose

#
protected virtual void Dispose(
disposing
)

Render

#
Render the capsule onto a graphics context.
public void Render(
G,
Graphics object to draw with. Zoom factor is implied by the G.Transform property.
selected,
If true, the capsule will be drawn with selected colours.
locked,
If True, the capcule will be drawn in Locked style.
hidden
If True, the capsule will be drawn in Hidden style.
)

Render

#
Have this capsule draw itself onto a Graphics surface with a custom colour override.
public void Render(
G,
Graphics object to draw with. Zoom factor is implied by the G.Transform property.
Color
colour
Base colour for the capsule. Other colours will be derived from the base colour. If you want full control over every colour involved, then use the overload that allows you to supply a custom Style instead.
)

Render

#
Have this capsule draw itself onto a Graphics surface with a custom Style override.
public void Render(
G,
Graphics object to draw with. Zoom factor is implied by the G.Transform property.
style
Style to draw capsule with.
)

Render

#
Render the capsule onto a graphics context.
public void Render(
G,
Graphics object to draw with. Zoom factor is implied by the G.Transform property.
icon,
Icon to render in center of content/bounding box.
selected,
If true, the capsule will be drawn with selected colours.
locked,
If True, the capcule will be drawn in Locked style.
hidden
If True, the capsule will be drawn in Hidden style.
)

Render

#
Have this capsule draw itself onto a Graphics surface with a custom colour override.
public void Render(
G,
Graphics object to draw with. Zoom factor is implied by the G.Transform property.
icon,
Icon to render in center of content/bounding box.
Color
colour
Base colour for the capsule. Other colours will be derived from the base colour. If you want full control over every colour involved, then use the overload that allows you to supply a custom Style instead.
)

Render

#
Have this capsule draw itself onto a Graphics surface with a custom Style override.
public void Render(
G,
Graphics object to draw with. Zoom factor is implied by the G.Transform property.
icon,
Icon to render in center of content/bounding box.
style
Style to draw capsule with.
)

SetJaggedEdges

#
Assign left and right jagged edges.
public void SetJaggedEdges(
left,
right
)