CarnegieMellonGraphics2
Class Style
in CarnegieMellonGraphics.h
- class Style
Style objects are used to encapsulate several pieces of style information
to be passed to drawing calls. At the most basic level styles store color
information, but they also contain information about line-widths,
the type of raster operation to use when rendering, and what pattern to use
when drawing lines and outline primatives.
So if you want to draw a green line you could create a style like so:
Style mystyle = Style(Color::GREEN);
or
Style mystyle = Style(Color(0,0,255));
However, when you draw your line it will only be one pixel thick. If you
want a thicker green line (3 pixels wide) you can do the following:
Style mystyle = Style(Color::GREEN, 3);
In another situation you might want to create an rubber-banding box by
XORing and outline rectangle, so you would create the following style:
Style mystyle = Style(Color::BLUE, 2, Style::XOR_OP);
Patterns for lines, arcs, and curves are represented using 16 bits.
Inner Classes, Typedefs, and Enums |
typedef |
Style::RasterOp
Possible raster operations
COPY_OP | Simply draw the color, default behavior |
INVERT_OP | Invert the drawing surface's color |
XOR_OP | XOR drawing surface with color |
AND_OP | AND drawing surface with color |
OR_OP | OR drawing surface with color |
|
Field Summary |
static const Style |
BLACK
|
static const Style |
BLUE
|
static const Style |
GREEN
|
static const Style |
INVERTED
|
static const Style |
RED
|
static const Style |
WHITE
|
Constructor Summary |
Style( Color col, int lwidth = 1, Style::RasterOp rop = COPY_OP, const std::vector< bool >& newpattern = defaultpattern )
Construct a style from a set of parameters |
Style( const Style& s )
|
BLACK
public static const Style BLACK;
BLUE
public static const Style BLUE;
GREEN
public static const Style GREEN;
INVERTED
public static const Style INVERTED;
RED
public static const Style RED;
WHITE
public static const Style WHITE;
Style
public Style( Color col, int lwidth = 1, Style::RasterOp rop = COPY_OP, const std::vector< bool >& newpattern = defaultpattern );
- Construct a style from a set of parameters
Style
public Style( const Style& s );
flipPatternBit
public void flipPatternBit( int position );
getColor
public Color getColor() const;
getLineWidth
public int getLineWidth() const;
getPattern
public std::vector< bool > getPattern() const;
getPatternAsUShort
public unsigned short getPatternAsUShort() const;
getRasterOp
public Style::RasterOp getRasterOp() const;
operator!=
public bool operator!=( const Style& rhs ) const;
- Comparison operator for inequality on style objects
operator=
public Style& operator=( const Style& rhs );
operator==
public bool operator==( const Style& rhs ) const;
- Comparison operator for equality on style objects
setColor
public void setColor( Color col );
setLineWidth
public void setLineWidth( int value );
setPattern
public void setPattern( const std::vector< bool >& newpattern );
setRasterOp
public void setRasterOp( Style::RasterOp rop );