Mapping Modes
Mapping Modes
COLORS
COLOR
appearance of an object
- Each one represented in 8-bits and the value for each color
ranges from 0-255
- As the pixels close to each other have different colors, the effect
-The bits of the most significant byte (the left byte) are reserved
for the operating system's internal use and must be set to 0
- The 32-bit numeric value used to characterize a color is
defined
by the COLORREF data type
- Declared as
COLORREF NewColor;
- After declaring initialize it with a 32-bit numeric value.It can be
done as follows
COLORREF NewColor = 16711935;
- Although the above number is a legitimate color value it does
not mean much
- One macro is defined to create a color called RGB macro. Its
syntax is
COLORREF RGB(BYTE byRed, BYTE byGreen, BYTE
byBlue);
RGB MACRO
- The RGB macro behaves like a function and allows you to pass
three numeric values separated by a comma.
- FONT CREATION
- FONT SELECTION
FONT CREATION
CFont NewFont;
• CreatePointFont
• CreateFont
• CreateFontIndirect
CreatePointFont Method
- Its syntax is
-Its syntax is
BOOL CreateFontIndirect(const LOGFONT* lpLogFont);
+Y
- For example, consider the code for creating an
ellipse
DEFAULT COORDINATE SYSTEM
void CExoDraw1View::OnPaint()
{
CPaintDC dc(this); // device context for painting
// A circle whose center is at the origin (0, 0)
dc.Ellipse(-50, -50, 50, 50);
// A line that starts at (0, 0) and ends at (100, 100)
dc.MoveTo(0, 0);
dc.LineTo(100, 100);
}
- The output of this is shown in the figure as follows
CHANGING COORDINATE SYSTEM
void CExoDraw1View::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.SetViewportOrg(200, 150);
// A circle whose center is at the origin (0, 0) dc.Ellipse(-50, -50,
50, 50);
// A line that starts at (0, 0) and ends at (100, 100)
dc.MoveTo(0, 0);
dc.LineTo(100, 100);
}
MAP MODES
MM_TEXT,
MM_LOENGLISH
MM_HIENGLISH
MM_ANISOTROPIC
MM_HIMETRIC
MM_ISOTROPIC
MM_LOMETRIC
MM_TWIPS
MM_TEXT
- horizontal axis moves from (0, 0) to the right and the vertical axis
moves from (0, 0) down
+Y
0,0 +X
* Each unit of measure provided is divided by 100
(unit/100)