GH_GraphicsUtilBlendInteger Method |
Calculates a linear blend between two extremes. Although the inputs
are unlimited integers, the output is an integer in the byte range (0-255).
Namespace:
Grasshopper.GUI
Assembly:
Grasshopper (in Grasshopper.dll)
Syntax public static int BlendInteger(
double t0,
double t1,
int a0,
int a1,
double t
)
Public Shared Function BlendInteger (
t0 As Double,
t1 As Double,
a0 As Integer,
a1 As Integer,
t As Double
) As Integer
Parameters
- t0
- Type: SystemDouble
Value of first extreme. - t1
- Type: SystemDouble
Value of second extreme. - a0
- Type: SystemInt32
Integer value at first extreme. - a1
- Type: SystemInt32
Integer value at second extreme. - t
- Type: SystemDouble
Interpolation parameter.
Return Value
Type:
Int32Interpolated value.
Examples This function is useful when you need to link colour alpha amounts to zoom levels:
Sub DrawZoomAwareCircle(ByVal G As Graphics, _
ByVal center As PointF, _
ByVal radius As Single, _
ByVal fill As Color)
Dim zoom As Single = G.Transform.Elements(0)
If (zoom < 0.25f) Then Return
Dim alpha As Int32 = GH_GraphicsUtil.BlendByte(0.25, 0.95, 0, 255, zoom)
G.FillEllipse(center.X - radius, center.Y - radius, _
2.0f * radius, 2.0f * radius, _
New SolidBrush(Color.FromARGB(alpha, fill)))
End Sub
See Also