PLUG'N SCRIPT
rapid plugin development
Tutorial
DSP
KUIML
How-to
Scripts
  • Overview
  • Tutorial
  • Reference
Layout and positioning
  • CELL
  • TABLE
Language basics
  • SKIN
  • DUMMY
  • INCLUDE
  • INCLUDE_ONCE
  • DEFINE
  • UNDEFINE
  • VARIABLE
  • LOCAL_VARIABLE
  • TEMPLATE
  • TEMPLATE_INNER_CONTENT
  • TEMPLATE_UNLOAD
  • REPEAT
Text widgets
  • TEXT
  • TEXT_FIELD
  • TEXT_EDIT_BOX
  • TOOLTIP
  • PARAM_TEXT
  • PARAM_TEXT_CONTROL
  • PARAM_TEXT_EDIT_BOX
  • PARAM_TOOLTIP
Image widgets
  • IMAGE
  • IMAGE_ACTION_BUTTON
  • IMAGE_GROUP_BOX
  • IMAGE_PARAM_BUTTON
  • IMAGE_PARAM_KNOB
  • IMAGE_PARAM_LINEAR_METER
  • IMAGE_PARAM_MENU_BUTTON
  • IMAGE_PARAM_METER
  • IMAGE_PARAM_SLIDER
  • IMAGE_PARAM_TOGGLE_SWITCH
  • XYZ_IMAGE_PARAM_JOYSTICK
Invisible controls
  • INVISIBLE_ACTION_BUTTON
  • INVISIBLE_PARAM_BUTTON
  • INVISIBLE_PARAM_KNOB
  • INVISIBLE_PARAM_MENU_BUTTON
  • INVISIBLE_PARAM_SLIDER
  • INVISIBLE_PARAM_TOGGLE_SWITCH
  • XY_PARAM_PAD
  • XY_ZOOM_SELECT_PAD
  • XYZ_PARAM_SCRATCH_PAD
  • XYZ_PARAM_CLICK_PAD
Drawing, curves & 3D
  • CANVAS
    • Graphics API
  • svg
  • CURVE_GRAPH
  • XY_CURVES_GRAPH
  • GRID
  • RULER
  • COLOR_SCALE
  • VIEW_3D
  • COLOR_SURFACE_3D
  • GRID_3D
  • GL_OBJECT_3D
    • OpenGL Cheat Sheet
  • SURFACE_COLORMAP_2DPLOT
Miscellaneous
  • SCRIPT
  • WIDGET
  • KUIML_WIDGET
  • POPUP_MENU
  • MENU_ITEM
  • MENU_SEPARATOR
  • FILE_SELECT_MENU
  • SYSTEM_ACTION_BUTTON
  • SYSTEM_PARAM_CHECKBOX
  • SYSTEM_PARAM_DROPDOWN_LIST
  • WINDOW
  • LOAD_FONT
Data model
  • STRING
  • PARAM
  • FORMULA_PARAM
  • PARAM_ANIMATOR
  • ACTION
    • Built-in action types
  • TIMER
  • ACTION_TRIGGER
  • CURVE
  • FORMULA_CURVE
  • CURVE_FROM_PARAM_OVER_TIME
  • SURFACE
  • FORMULA_SURFACE
  • SURFACE_FROM_CURVE_OVER_TIME
  • GROUP
Links and commands
  • PARAM_LINK
  • PARAM_MULTI_LINK
  • PARAM_CONNECTION
  • PARAM_TO_STRING_LINK
  • STRING_LINK
  • STRING_MULTI_LINK
  • CURVE_LINK
  • CURVE_MULTI_LINK
  • SURFACE_LINK
  • REQUIRED_OBJECTS
  • EXPOSED_OBJECTS
  • PERSISTENT_OBJECTS
Common attrubutes
  • For all elements
  • Widgets
  • Param Widgets
  • Param Controls
  • Param Info Viewers
  • Text Widgets
  • Surface Viewers
  • Curve Viewers
  • Images
  • 3D Objects
Additional information
  • All attributes
  • Attribute types
  • Cursors
  • Math formulas
  • Scripting
    • Built-in addons
  • User experience
  • Errors and solutions
  • Built-in variables
  • Runtime model
  • Parameters mapping
  • Script converter
  • LetiMix
KUIMLReferenceFORMULA_CURVE
August 21, 2025

FORMULA_CURVE

This element creates a curve defined by a mathematical formula (y=f(x)).

Attributes brief detailed show all inherited

Name DescriptionDefault
formulaMathematical formula for the curveThe formula can reference any other model data available (parameter, curve, surface...)empty
variablename of the "x" variable in the formulaYou can customize the name of the traditional "x" variable in y=f(x) formula so that it becomes y=f(variable)x
Events
Exposed: v. 2.0value_changedthe event is triggered anytime the value of the object has changed
Common attributesRead about `common`
idIdentifier of the elementThe id of an element has to be globally unique. Don't start with a digit for AngelScript compatibility.empty
Name Value type Default Description Comment
formulaMath FormulaemptyMathematical formula for the curveThe formula can reference any other model data available (parameter, curve, surface...)
variablestringxname of the "x" variable in the formulaYou can customize the name of the traditional "x" variable in y=f(x) formula so that it becomes y=f(variable)
Events
Exposed: v. 2.0value_changedeventthe event is triggered anytime the value of the object has changed
Common attributesRead about `common`
ididentifieremptyIdentifier of the elementThe id of an element has to be globally unique. Don't start with a digit for AngelScript compatibility.

See the CURVE element attributes. The FORMULA_CURVE element does not have the persistent attribute since its value is computed automatically.

Examples

A simple FORMULA_CURVE and other elements used to display that curve on a graph nicely.

  1. <!-- demo of a formula curve -->
  2. <FORMULA_CURVE id="formula_curve_demo" x_min="-50" x_max="50" x_default="0" y_default="0" y_max="1" y_min="-1" formula="sin(x)/x" />

  3. <!-- display the curve on a graph -->
  4. <PNS_LCD_GROUP_BOX>
  5. <LAYER_STACK>
  6. <!-- grid -->
  7. <GRID id="grid_1" width="100%" height="100%" x_positions_count="11" x_subdiv_count="1" y_positions_count="3" y_subdiv_count="3" color="#CCCCCC" subdiv_color="#999999" origin_color="#FFFFFF" line_width="2" subdiv_line_width="1" origin_line_width="3" x_param_info_id="formula_curve_demo.x_info" y_param_info_id="formula_curve_demo.y_info" opacity="0.2" />

  8. <!-- first graph for the line (stroke) -->
  9. <CURVE_GRAPH curve_id="formula_curve_demo" width="500" height="200" color="#327ca3" graph_style="stroke" opacity="1" line_width="4" />
  10. <!-- second line for the opaque bargraph -->
  11. <CURVE_GRAPH curve_id="formula_curve_demo" width="500" height="200" color="#327ca3" graph_style="bargraph" opacity="0.2" line_width="4" />

  12. <!-- horizontal ruler -->
  13. <RULER id="graph_ruler_x" orientation="horizontal" width="100%" value_suffix="false" param_info_id="formula_curve_demo.x_info" color="#AAAAAA" value_format=".1" content="{value}" positions_count="11" font_escapement="0" text_h_align="center" v_offset="0" v_align="bottom" h_offset="-1" font_size="12" />

  14. <!-- vertical ruler -->
  15. <RULER id="graph_ruler_y" orientation="vertical" height="100%" width="50" value_suffix="false" param_info_id="formula_curve_demo.y_info" color="#999999" value_format=".1" content="{value}" positions_count="3" font_escapement="0" text_v_align="top" h_align="left" text_h_align="left" h_offset="3" v_offset="0" font_size="12"/>
  16. </LAYER_STACK>
  17. </PNS_LCD_GROUP_BOX>

Changing variable name

Just for "cosmetic" purposes we can change the name of the variable used in the formula (instead of default "x"), so that it's maybe easier to read. 

  1. <FORMULA_CURVE id="formula_curve_demo" x_min="-50" x_max="50" x_default="0" y_default="0" y_max="1" y_min="-1" formula="sin(pos)/pos" variable="pos" />

Complex curves

You can create complex formulas for complex curves using methods like this:

  1. <!-- stepped formula curve -->
  2. <FORMULA_CURVE id="formula_curve_demo" x_min="0" x_max="7" x_default="0" y_default="0" y_max="5" y_min="-5" formula="0 + 1*(x>=1)*(x&lt;2) + 2*(x>=2)*(x&lt;3) + -3*(x>=3)*(x&lt;4) + -1*(x>=5)*(x&lt;6)" />

A smoothed curve can be achieved using tahh or similar functions.

  1. <!-- stepped formula curve -->
  2. <FORMULA_CURVE id="formula_curve_demo" x_min="0" x_max="7" x_default="0" y_default="0" y_max="5" y_min="-5" formula="0 + ((1+tanh(k*(x - 1)))/2)*(1-0) + ((1+tanh(k*(x - 2)))/2)*(2-1) + ((1+tanh(k*(x - 3)))/2)*(-3-2) + ((1+tanh(k*(x - 4)))/2)*(0--3) + ((1+tanh(k*(x - 5)))/2)*(-1+0) + ((1+tanh(k*(x - 6)))/2)*(0--1) " />

  3. <!-- smoothing value -->
  4. <PARAM id="k" min="2" max="30" exposed="true" default="7" />

  5. <!-- control -->
  6. <PARAM_TEXT_CONTROL param_id="k" />

You can take a look at this script that does similar stuff in a more complex/organized manner.

Keep in mind that drawing complex curves (and other graphics) can be done using CANVAS.

Related elements

See CURVE_GRAPH, CURVE_FROM_PARAM_OVER_TIME, GRID, RULER, CURVE, CURVE_LINK, CANVAS.


Comments

Please, authorize to view and post comments.

2020 - 2026 © Site by LetiMix · Donate  |  Plug'n Script and KUIML by Blue Cat Audio