• Geometry 3D
  • Printing
  • Images
  • Audio
  • Films

  • Regions
  • Bundles
  • Matrices
  • Fonts
  • Text



Bundles

A bundle on macOS is very much different from the TBundle discussed here. But usage of the term here predates the macOS one, so there. It comes from the NuGraf proposal at Apple by Mark C, the author of the original MacDraw application. The idea was to collect in one object all the graphics state required for a drawing operation. The Albert project used this convention and Guildhall uses it as well, but I have yet to fill out its full capability, mostly because I haven't yet had much need for the extra goodies. Here's some of the state it might contain:

  • draw operation (fill, frame, or both)
  • fill color
  • frame color
  • pen width
  • fill operation (normal, lighten, darken, min, max, etc)
  • fill effects (gradient, patterns, images, etc)
  • frame operation (likewise)
  • frame effects (likewise)
  • pen endcaps (rounded, square, arrow)
  • pen joins (rounded, mitered)
  • pen pattern
  • pen offset (inset, outset, or centered)
  • pen shape

In practice I've gotten as far as the draw operation, the fill and frame colors, and the pen width. I've done some inconsistent work on the fill and frame operations. The method calls are there for the other features but I tend to let usage drive implementation and I just haven't needed them yet.

The practical advantage of this approach is avoiding repeated setup calls for the port. Anything the port needs for drawing is right in the bundle, and in theory the architecture could cache expensive setup. But as I said, I haven't needed that stuff yet.

One comment about bundles. They can be constructed in three ways.


TBundle ( const TColor& fill );                                       // for fill only
TBundle ( const TColor& frame, Coord penWidth );                      // for framing
TBundle ( const TColor& fill, const TColor& frame, Coord penWidth);   // for both


This is by far the most convenient way to set the draw operation to fill, frame, and both, though that can also be set explicitly. But also note that although these methods are shown taking a TColor parameter, the actual constructors require TPaint instances. TPaint can take a TColor in its constructor, so C++ automatically promotes TColor to a TPaint. The reason they take a TPaint object is so color operation information could be included, for example operations for additive color, subtractive color, lightening, or darkening. This hasn't been nearly as useful since alpha channel usage became ubiquitous, but I expect that I'll use them again when the Paint applet gets farther along.

Constructible Classes

  • TColor
  • TRGBColor (helper class, takes numbers in the range 0 .. 255)
  • TPaint
  • TBundle

 

Copyright © 1981-2021 Arthur W Cabral. All Rights Reserved. All referenced trademarks are the property of their respective owners. This site does not use cookies. This site does not collect visitor information. The ISP hosting this site collects statistics regarding visitors to this site as part of the normal operation of the website. We do not currently examine those statistics. If that changes, this notice will change. Mac and macOS are registered trademarks of Apple, Inc.