Name

addFill( )

Synopsis

$fill = $shape->addFill(r, g, b [, a])
$fill = $shape->addFill(bitmap [, flags])
$fill = $shape->addFill(gradient [, flags])

Each shape contains a list of fill styles, any or all of which may be used to draw the shape. This method creates a new SWF::Fill object that can be used with setLeftFill( ) or setRightFill( ). The method can be called in one of three ways:

  1. If called with RGBA components, a solid fill is added to the shape’s fill style list.

  2. If called with an SWF::Bitmap object, a bitmap fill is added to the shape’s fill style list. The flags argument can be:

    SWF::Fill::SWFFILL_TILED_BITMAP (the default)
    SWF::Fill::SWFFILL_CLIPPED_BITMAP
  3. If an SWF::Gradient object is the first argument, a gradient fill is added to the shape’s list of fill styles. The flags argument can be:

    SWF::Fill::SWFFILL_LINEAR_GRADIENT (the default)
    SWF::Fill::SWFFILL_RADIAL_GRADIENT

Note that the fill must be created with the addFill( ) method, and each fill object is associated with a particular Shape object. In the case of a gradient fill, the gradient must be defined before the shape is created. Fill objects cannot be used interchangeably between shape objects. Figure 9-4 shows illustrations of the bitmap and gradient fill styles.

Bitmap and gradient fill flags: a) SWFFILL_CLIPPED_BITMAP, b) SWFFILL_TILED_BITMAP, c) SWFFILL_RADIAL_GRADIENT, and d) SWFFILL_LINEAR_GRADIENT
Figure 9-4. Bitmap and gradient fill flags: a) SWFFILL_CLIPPED_BITMAP, b) SWFFILL_TILED_BITMAP, c) SWFFILL_RADIAL_GRADIENT, and d) SWFFILL_LINEAR_GRADIENT

Get Perl Graphics Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.