MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes
MFM::Drawing Class Reference

#include <Drawing.h>

Public Member Functions

 Drawing (SDL_Surface *dest=0, TTF_Font *font=0)
 
void TransformWindow (const Rect &rect)
 
void GetWindow (Rect &rect) const
 
void SetWindow (const Rect &rect)
 
void Reset (SDL_Surface *dest, TTF_Font *font)
 
void Clear ()
 
u32 GetBackground () const
 
u32 SetBackground (const u32 color)
 
u32 GetForeground () const
 
u32 SetForeground (const u32 color)
 
TTF_Font * GetFont () const
 
TTF_Font * SetFont (TTF_Font *newFont)
 
TTF_Font * SetFont (FontAsset asset)
 
void DrawHLine (int y, int startX, int endX) const
 
void DrawVLine (int x, int startY, int endY) const
 
void DrawRectangle (const Rect &rect) const
 
void FillRect (int x, int y, int w, int h) const
 
void FillRect (int x, int y, int w, int h, u32 color) const
 
void FillRect (const Rect &rect) const
 
void FillCircle (int x, int y, int w, int h, int radius) const
 
void BlitText (const char *message, UPoint loc, UPoint size) const
 
void BlitBackedText (const char *message, UPoint loc, UPoint size)
 
void BlitBackedTextCentered (const char *message, UPoint loc, UPoint size)
 
SPoint GetTextSize (const char *message)
 
SPoint GetTextSizeInFont (const char *message, TTF_Font *thisFont)
 
void BlitImage (SDL_Surface *image, UPoint loc, UPoint maxSize) const
 
void BlitAsset (Asset asset, UPoint loc, UPoint maxSize) const
 

Static Public Member Functions

static u32 HalfColor (u32 input)
 
static u32 InterpolateColors (const u32 color1, const u32 color2, u32 percentOfColor1)
 
static void TransformWindow (const Rect &existing, const Rect &newTransform, Rect &result)
 
static void Convert (const Rect &rect, SDL_Rect &toFill)
 

Static Public Attributes

static const int WHITE = 0xffffffff
 
static const int BLACK = 0xff000000
 
static const int RED = 0xffff0000
 
static const int GREEN = 0xff00ff00
 
static const int BLUE = 0xff0000ff
 
static const int CYAN = 0xff00ffff
 
static const int MAGENTA = 0xffff00ff
 
static const int YELLOW = 0xffffff00
 
static const int GREY05 = 0xff0c0c0c
 
static const int GREY10 = 0xff191919
 
static const int GREY20 = 0xff333333
 
static const int GREY30 = 0xff4c4c4c
 
static const int GREY40 = 0xff666666
 
static const int GREY50 = 0xff7f7f7f
 
static const int GREY60 = 0xff999999
 
static const int GREY70 = 0xffb2b2b2
 
static const int GREY80 = 0xffcccccc
 
static const int GREY90 = 0xffe5e5e5
 
static const int GREY95 = 0xfff2f2f2
 
static const int GREY = GREY50
 
static const int DARK_PURPLE = 0xff200020
 
static const int ORANGE = 0xffff6600
 

Detailed Description

Low-level-ish drawing context and methods. A Drawing is something like a GraphicsContext in Java.

Member Function Documentation

void MFM::Drawing::BlitAsset ( Asset  asset,
UPoint  loc,
UPoint  maxSize 
) const

Draw a specified Asset (corresponding to an SDL_Surface*) to the screen.

void MFM::Drawing::BlitBackedText ( const char *  message,
UPoint  loc,
UPoint  size 
)

Draw a message in the current font using the current background color as a backing color to another drawn layer using the foreground color. Fail ILLEGAL_STATE if the current font is null.

void MFM::Drawing::BlitBackedTextCentered ( const char *  message,
UPoint  loc,
UPoint  size 
)

Just like BlitBackedText but center message

void MFM::Drawing::BlitImage ( SDL_Surface *  image,
UPoint  loc,
UPoint  maxSize 
) const

Draw a specified image to a specified part of the screen.

void MFM::Drawing::BlitText ( const char *  message,
UPoint  loc,
UPoint  size 
) const

Draw message in the current font using the current foreground color. Fail ILLEGAL_STATE if the current font is null.

void MFM::Drawing::Clear ( )

Fill with current background color

void MFM::Drawing::DrawHLine ( int  y,
int  startX,
int  endX 
) const

Draw a one-pixel high horizontal line in the current foreground color

void MFM::Drawing::DrawRectangle ( const Rect rect) const

Draw a box with one-pixel lines just inside the given Rect, in the current foreground color

void MFM::Drawing::DrawVLine ( int  x,
int  startY,
int  endY 
) const

Draw a one-pixel wide vertical line in the current foreground color

void MFM::Drawing::FillCircle ( int  x,
int  y,
int  w,
int  h,
int  radius 
) const

Fill a circle of the given radius with the current foreground color. The center of the circle is at (x+w/2, y+h/2).

void MFM::Drawing::FillRect ( int  x,
int  y,
int  w,
int  h 
) const

Fill the given rectangle with the current foreground color

void MFM::Drawing::FillRect ( int  x,
int  y,
int  w,
int  h,
u32  color 
) const

Fill the given rectangle with the given color, without changing the foreground color

void MFM::Drawing::FillRect ( const Rect rect) const
inline

Fill the given rectangle with the current foreground color

u32 MFM::Drawing::GetBackground ( ) const
inline

Get the current background color.

TTF_Font* MFM::Drawing::GetFont ( ) const
inline

Get the current font. May return null. Text operations will fail ILLEGAL_STATE if attempted with a null font.

u32 MFM::Drawing::GetForeground ( ) const
inline

Get the current foreground color.

SPoint MFM::Drawing::GetTextSize ( const char *  message)

Return the SPoint(width, height) of message when rendered in the current font, or SPoint(-1,-1) if any problem occurs

SPoint MFM::Drawing::GetTextSizeInFont ( const char *  message,
TTF_Font *  thisFont 
)

Return the SPoint(width, height) of message when rendered in thisFont, or SPoint(-1,-1) if any problem occurs

void MFM::Drawing::GetWindow ( Rect rect) const

Access the current drawing window.

u32 MFM::Drawing::InterpolateColors ( const u32  color1,
const u32  color2,
u32  percentOfColor1 
)
static

Return a weighted average of color1 and color2, averaging the RGBA components separately. If percentOfColor1 is 0, return color2. If percentOfColor1 is 100 or greater, return color1.

Such linear mixing in RGBA works okay when mixing with white or black, but in general it isn't necessarily sensible in physical or perceptual terms.

void MFM::Drawing::Reset ( SDL_Surface *  dest,
TTF_Font *  font 
)

Reset Drawing based on surface and given font

u32 MFM::Drawing::SetBackground ( const u32  color)
inline

Set the background color. Returns prior value

TTF_Font* MFM::Drawing::SetFont ( TTF_Font *  newFont)
inline

Set the current font. Null may be passed in to clear the current font. Text operations will fail ILLEGAL_STATE if attempted with a null font. Returns prior value.

TTF_Font* MFM::Drawing::SetFont ( FontAsset  asset)
inline

Set the current font to one loaded by the AssetManager.

Parameters
assetThe FontAsset of the font to load into this Drawing instance.
returnsThe TTF_Font which was loaded by this Drawing instance before calling this method.
u32 MFM::Drawing::SetForeground ( const u32  color)
inline

Set the foreground color. Returns prior value

void MFM::Drawing::SetWindow ( const Rect rect)

Set the current drawing window.

void MFM::Drawing::TransformWindow ( const Rect rect)

Update the drawing window. The GetX() and GetY() of rect provide the position of (0,0), relative to the previous window, and the GetWidth() and GetHeight() of rect provide the bounds for drawing (clipped against the prior bounds, if any).

void MFM::Drawing::TransformWindow ( const Rect existing,
const Rect newTransform,
Rect result 
)
static

Compute a the drawing window update. This is what TransformWindow uses to control drawing, and also what the mouse dispatching uses to determine who sees events.


The documentation for this class was generated from the following files: