Type parameters:
| T | Type of Function to wrap. where Function |
Constructors
Fields
_inner
protected Color _inner
Actual state of the inner colour as determined by the SetupDrawing method.
_outer
protected Color _outer
Actual state of the outer colour as determined by the SetupDrawing method.
Properties
Arguments
Gets all the arguments associated with this function. Arguments can be either of type Vector (i.e. 2D grips) or Scalar (i.e. 1D sliders) or referents (i.e. 1D functions).
AssumeContinuous
Override this property and return false if the underlying function is expected to contain discontinuities.
GripsOn
Gets or sets whether the grips (and scalars) of this function ought to be drawn.
LatestGraphSegments
The polyline segments the graph was most recently drawn with, in graph (content) coordinates. Empty when the function hasn't been drawn yet. Populated by FunctionUi.DrawGraph(FunctionGraphics) from whatever FunctionUi.GraphSegments(FunctionGraphics) yields, so subclasses that override GraphSegments (LinearFunction, ThresholdFunction, etc.) contribute here too. Hit-testing uses these so the click tolerance matches the rendered pixels exactly.
Rank
Gets or sets the stature of this function. The stature controls the visual style of the function, as well as its inclusion in any outputted collection.
Tint
Gets or sets the Open-Color family used to tint this function. A concrete shade is resolved at draw time based on the current background so the function stays legible under any theme. Use FunctionUi.TintFor(Color) when a concrete Color is needed.
VariableArguments
Override this property if your function has a variable number of vector arguments.
Methods
AfterDrawGraphSegments
Draw any decoration that should appear on top of the graph polyline. Called from FunctionUi.DrawGraph(FunctionGraphics) after the polyline has been rendered.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
BeforeDrawGraphSegments
Draw any decoration that should appear behind the graph polyline. Called from FunctionUi.DrawGraph(FunctionGraphics) after FunctionUi.GraphSegments(FunctionGraphics) has run, so FunctionUi.LatestGraphSegments is populated and available.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
CanInsertVector
#Test whether a grip can be inserted at or near a coordinate.
Parameters:
| location (Point2d) | Initial grip insertion coordinate. |
| actualLocation (out Point2d) | Modified grip insertion coordinate. |
Returns: True if grip can be inserted at modifiedCoordinate.
Overrides: FunctionUi.CanInsertVector
CanRemoveVector
#Override this method to specifically okay removal off a specific grip.
Parameters:
| vector (VectorArgument) |
Overrides: FunctionUi.CanRemoveVector
CreateFromArguments
#protected abstract T CreateFromArguments()
This method is called by the base class whenever the equation needs to be updated to reflect the current grip state.
DrawGraph
Draw this function graph into a graphics context. Non-virtual: subclasses customise the rendering via FunctionUi.GraphSegments(FunctionGraphics) (the polyline itself) and the FunctionUi.BeforeDrawGraphSegments(FunctionGraphics) / FunctionUi.AfterDrawGraphSegments(FunctionGraphics) hooks (any decorations before or after the curve). This keeps pen setup, rank thickness rules, obscure dashing, and segment capture in one place.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
DrawGripFlourishes
Draw all grip flourishes associated with this function.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
DrawGripShapes
Draw all grips associated with this function.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
DrawHints
Draw the visual hints such as asymptotes, limits and markers associated with this function.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
DrawScalarShapes
Draw all scalars associated with this function.
Parameters:
| graphics (FunctionGraphics) | Graphics object to draw with. |
EstimateDistance
Compute an estimate of the distance from the function to the given point. This estimate is done by sampling the function at small intervals around the point. Note: implementors may choose to override this method and provide analytic distance measurements.
EstimateProjection
Compute an estimate of the point on the function closest to a search point. This estimate is done by sampling the function at small intervals around the point.
GraphSegments
Override this method if you think you can provide a more performant way to generate a graphics path representing the graph curve.
Parameters:
| graphics (FunctionGraphics) | Drawing properties. |
OverrideFunctionCache
#[EditorBrowsable(EditorBrowsableState.Never)]
protected internal void OverrideFunctionCache(T function)
Override the cached function. You typically never need this. It's here for those rare cases where grips or scalars are modified in such a way so as to not affect the underlying function.
Parameters:
| function (T) |
SetupDrawing
Must be called prior to any draw method. This will ensure the colours and layout are correct.
Parameters:
| graphics (FunctionGraphics) | |
| animate (bool = true) |
TintFor
public Color TintFor(Color background)
Resolve FunctionUi.Tint into a concrete colour that stands out against the supplied background.
Parameters:
| background (Color) | Background the tint must contrast with. |
TryInsertVector
#Try and insert a grip at a coordinate.
Parameters:
| location (Point2d) | Grip location. |
Returns: True if grip was inserted.
Overrides: FunctionUi.TryInsertVector
TryRemoveVectors
#Try and remove a set of grips.
Parameters:
| vectors (VectorArgument[]) | Vectors whose removal is indicated. |
Returns: True if the function changed state.
Overrides: FunctionUi.TryRemoveVectors
Events
FunctionChanged
Raised when the shape of the function changes due to non-grip/scalar events, for example when the function is modified via a custom menu item.