Skip to content

CURVE ​

Draws two-dimensional function curves specified by parameters.

Syntax ​

leo-grammar
CURVE strValue fx:realValue fy:realValue from:realValue to:realValue .

Parameters ​

  • <main-parameter> (strValue) - The name of a variable that is used in expressions specified for fx and fy.
  • from (realValue) - The lower end of the interval for the variable provided through the <main-parameter>.
  • to (realValue) - The upper end of the interval for the variable provided through the <main-parameter>.
  • fx (realValue) - An expression specifying a function to calculate the x-coordinate using the variable from <main-parameter>.
  • fy (realValue) - An expression specifying a function to calculate the y-coordinate using the variable from <main-parameter>.

Details ​

The style of this command is defined by the PEN command.

For fx and fy LEO expressions have to be specified. They are used to calculate the x and y coordinates for values of the variable in the interval specified by from and to.

The expressions should not access variables other than the one specified through the <main-parameter>. Accessing other variables is possible, but terribly slow. Moving the curve can be easily achieved by adding or subtracting constant values in fx and fy. If the curve has to be moved or stretched dynamically, like in a loop or based on the size of a TABLE, then consider using the MAP command.

The width of a step is always exactly one pixel and thus depends on the output medium and the scaling factor chosen. In principle a clear representation is guaranteed, particularly when enlarging objects.

It is also possible to draw draw curved shapes by using the CURVE command in a COMPOUND sequence. The sequence may even consist of only one element (the curve itself).

See Also ​

Examples ​

Draw a simple sinus curve.
A sinus curve

leo-grammar
GRAPHREP
SHADOW off

CURVE "x" from:0 to:6.2831853 fx:(x) fy:(sin(x))

Draw a line resembling an open beaker.
A curved blue line resembling a beaker

leo
GRAPHREP
SHADOW off

PEN color:"steelblue" w:2pt
CURVE "t"
    from:-3.5 to:3.5
    fx:(sin(.77*t+sin(t))) fy:(.8*cos(t))

Draw a shape resembling a beaker with some perspective.
A shape resembling a beaker

leo
GRAPHREP
# Note: SHADOW is on by default.

PEN color:"steelblue" w:2pt
FILL color:"powderblue"
# Uses compound to close off the curve so that it can be filled.
COMPOUND 1
CURVE "t"
    fx:(sin(.77*t+sin(t))) fy:(.8*cos(t))
    from:-3.5 to:3.5
FILL color:"lightcyan"
ELLIPSE y:-0.8cm rx:0.72cm ry:0.2cm

Versions and Changes ​

Available since ADOxx 1.3