VML Reference Material - VML

This element defines a single value as the result of the evaluation of an expression. The expression is defined by the eqn attribute and has the general form of an operation followed by up to three arguments, which consist of adjustment values (see the adj attribute of the shape element (§6.1.2.19)), the results of earlier formulas, fixed numbers or pre-defined values. Each f value is referenced using "@" followed by a number corresponding to the zero-based index for that value in the list of f elements. For example, the value of the second f element is referenced as "@2".

[Example: The following defines a blue arrow pointing to the right:

path="m @0,0 l @0,@1 0,@1 0,@3 @0,@3 @0,21600 21600,10800 x e"

style='left:50pt;top:50pt;width:90pt;height:30pt'

fillcolor="#4f81bd" strokecolor="#4f81bd" strokeweight="2pt">

<v:formulas>

<v:f eqn="val #0"/>

<v:f eqn="val #1"/>

<v:f eqn="val #2"/>

<v:f eqn="sum height 0 #1"/>

<v:f eqn="sum #2 0 #1"/>

<v:f eqn="sum width 0 #0"/>

<v:f eqn="prod @5 @4 #2"/>

<v:f eqn="sum width 0 @6"/>

</v:formulas>

</v:shape>

The shape looks like this:

end example]

 Parent Elements formulas (§6.1.2.6)

Attributes

Description

eqn (Equation)

Specifies a single formula, which consists of a named operation followed by up to three parameters, typically described as v, P1 and P2. Up to 128 formulas may be specified. These operations are defined (calculation accuracy is discussed below):

 Operation Description val v Returns the supplied value. Exact. sum Addition and subtraction. Exact. product Multiplication and division. Rounds up. mid Simple average. Rounds toward zero. abs Absolute value. Exact. min The lesser of two values. Exact. max The greater of two values. Exact. if Conditional selection. Exact. mod Modulus. Inexact. atan2 Trigonometric arc tangent of a quotient. Result is in "fd" units or fractional degrees - degrees . Inexact. sin Sine. Argument is in "fd" units or fractional degrees - degrees . Inexact. cos Cosine. Argument is in "fd" units or fractional degrees - degrees . Inexact. cosatan2 Preserves full accuracy in the intermediate calculation. Inexact. sinatan2 Preserves full accuracy in the intermediate calculation. Inexact. sqrt Square root. Result is positive and rounds down. Inexact. sumangle Adds an existing angle in fd units (v) to two other angles specified in degrees. P1 and P2 are scaled by . Exact. ellipse The eccentricity formula for an ellipse, where v is length of the semiminor axis and P1 is the length of the semimajor axis. Inexact. tan Tangent. Argument is in "fd" units or fractional degrees - degrees . Inexact.

Formulas are evaluated to full precision, but the result is always a 32-bit integer. Formula authors should avoid formulas which are discontinuous - not only are many of the trigonometric operations inexact, the transformations within the coordinate spaces are also inexact. This can mean that a set of formulas which is discontinuous evaluates to give very different path values with the same input on two different systems.

When an operation is marked as exact then a conforming implementation must always generate the correct arithmetic answer (unless the calculations overflow internally). The product operation is required to round to the nearest integer. If the result is exactly 0.5 then it must be rounded up to the next numerically greater integer. The mid operation is required to round towards 0.

All other operations are inexact, but the implementation must round non-integral values down (towards -infinity) and should perform internal calculations with this form of rounding.

The arguments used in the evaluation of a formula are normally either fixed numbers, the result of the evaluation of a previous formula or an adjust value - the value of the corresponding entry in the shape adj attribute.  Fixed numbers must be positive integral values in the range 0 to 65535 (unsigned 16-bit numbers). The following named values are defined:

 Value Description @n The value of formula n, where n is the zero-based index of the formula in the list of formulas.  n must be less than the current formula index. #n Adjustment (adj) value n.  n must be in the range 0 to 7. width The width defined by the coordsize attribute. height The height defined by the coordsize attribute. xcenter The x ordinate of the center of the coordinate space defined by coordorigin and coordsize. ycenter The y ordinate of the center of the coordinate space defined by coordorigin and coordsize. xlimo The x value of the limo attribute (see also the path element (§6.1.2.14)). ylimo The y value of the limo attribute (see also the path element (§6.1.2.14)). hasstroke 1 if the shape has a stroke operation, 0 if it does not, as determined by the on attribute of the stroke element (§6.1.2.21). hasfill 1 if the shape has a fill operation, 0 if it does not, as determined by the on attribute of the fill element (§6.1.2.5). pixellinewidth The line width in output device pixels. This is used to outset lines from the edge of a rectangle on the assumption that the implementation draws to lower right pixel in preference to the upper left pixel when a line is on a pixel boundary. pixelwidth The width of the shape in device pixels (i.e., the coordsize width transformed into device space). pixelheight The height of the coordsize in device pixels. emuwidth The width of the coordsize in EMUs. emuheight The height of the coordsize in EMUs. emuwidth2 Half the width of the coordsize in EMUs. emuheight2 Half the height of the coordsize in EMUs.

The EMU, or English Metric Unit, is the smallest unit of measure in VML and corresponds to 914400 EMU per inch or 12700 EMU per point.

See above for an example.

The possible values for this attribute are defined by the XML Schema string datatype.

The following XML Schema fragment defines the contents of this element:

<complexType name="CT_F">

<attribute name="eqn" type="xsd:string"/>

</complexType>