C++  .NET  C#  Java  C  ASP  HTML  Prolog  Visual Basic  Javascript  JScript  VBScript  MFC  Perl  PHP  Basic  Python  C  Assembler  VB  Ada  Ruby  XML  ASP.NET  C++  Java
[warebiz] :: Programming Bizness

Specializing in programming tutorials that make sense!

 Programming Tutorials

 Resources     » Articles
    » Projects
    » CS Dictionary
    » References
    » Books

 Site     » Home
    » About
    » Support
    » Make Donation
binary digits
C++ Ripped Apart Tutorial
Section 8: User-Defined Types, Header Files, Graphics 

You are in Section 8 of 9, Article 8.3 of 8.4, Part 8.3.5 of 8.3.6

8 .. User-Defined Types, Header Files, and Graphics Intro
       8.3 .. Introduction To Graphics
              8.3.5 .. Colors and Text


Colors and Text

Specifying Colors
If needing to change or specify the color and/or pattern used for filling objects and regions, use the following function:



NOTE: setcolor() will specify the color used for the border of objects and normal drawing functions; setfillstyle() specifies the color to be used for the interior of objects.

There are 13 different patterns defined for the pattern of filling, including:

  • EMPTY_FILL (0)
  • SOLID_FILL (1)
  • SLASH_FILL (4)
  • BK_SLASH_FILL (5)
  • HATCH_FILL (7)
  • XHATCH_FILL (8)

The following section of code will draw a rectangle with a border of white and interior of red:



Displaying Graphical Text
Text can be displayed on the graphics window using the following functions:



The outtext() function displays the given string using the font, direction, and the size set by the settextstyle( ) function, which has three parameters; int font, int direction, and int size (1 - 10);



The default values for outtext() are as follows:



Direction may be one of the following: HORIZ_DIR (0) or VERT_DIR (1).

Using default values, the displayed text is practically unreadable. Experiment with the various settings to see which values appear the best for the program being written.

By default, outtext() positions the text such that the upper left corner of the first character is positioned in the current position. outtextxy() is similar to outtext() except the upper left corner of the first character is positioned at (x, y).

The settextjustify() function can be used to control the horizontal and vertical position of the text relative to the current position or (x, y). It requires two parameters: horizontal and vertical and has the following form:



The horizontal parameter may be:

  • LEFT_TEXT (0)
  • CENTER_TEXT (1)
  • RIGHT_TEXT (2)

The horizontal parameter determines whether the text starts at the current position, is centered at the current position, or ends at the current position.

The vertical parameter may be:

  • BOTTOM_TEXT (0)
  • CENTER_TEXT (1)
  • TOP_TEXT (2)

The vertical parameter determines whether the text is displayed above the current position, centered at the current position, or below the current position. The default values for settextjustify() are LEFT_TEXT and TOP_TEXT.

In the next part, we'll put what we've learned into action by studying example graphics programs.

Read on for more...

Next: Specific Examples

You are in Section 8 of 9, Article 8.3 of 8.4, Part 8.3.5 of 8.3.6

[Back to Top]

Google
 
Web warebizprogramming.com

.: Report Bug : Error Log : About Webmaster :.

Search Warebiz!
binary digits binary digits

 Random Insight ::

binary digits

 Book References ::

binary digits
 C++  .NET  C#  Java  C  ASP  HTML  Prolog  Visual Basic  Javascript  JScript  VBScript  MFC  Perl  PHP  Basic  Python  C  Assembler  VB  Ada  Ruby  XML  ASP.NET  C++  Java