defineFigureGenerator static method

void defineFigureGenerator(
  1. String name,
  2. Object func
)

This static function defines a named figure geometry generator for Shapes. Once this is called one can use the name as a value for Shape#figure.

The first argument is the new figure name and must be a non-empty string that starts with a capital letter and that is not "None".

If the second argument is a string this call defines a synonym for an existing figure generator. Do not define cycles of synonyms -- the behavior will be undefined.

If the second argument is a function, the Geometry generator function's first argument is the Shape for which the function is producing a Geometry. But this Shape argument may be null in some circumstances. The second and third arguments are the desired width and height. These will always be finite non-negative numbers. The function may look at the Shape#parameter1 and Shape#parameter2 properties, which may be NaN, to decide what geometry to create for the figure given its intended width and height.

The function must return a Geometry; you may want to set Geometry#spot1 and Geometry#spot2 on it to indicate where content should be placed within the figure when using an "Auto" Panel. For some figures you may also want to set Geometry#defaultStretch to GraphObject.Uniform in order to maintain the geometry's aspect ratio within the Shape.

Generated figures must create a Geometry that is not larger than the supplied with and height. Doing so will signal an error.

Implementation

static void defineFigureGenerator(
  _i2.String name,
  _i2.Object func,
) {
  _i4.callMethod(
    _declaredShape,
    'defineFigureGenerator',
    [
      name,
      func,
    ],
  );
}