Wednesday, December 5, 2007

Fitz And Floyd Christmas China Retired

12) Discussion (text Debug)

I think we need a study on 'use of text debugging! Not all programmers want to use graphics, even at times there is not really needed and you can get something nice and cute even without using it. What we do is change the location in which to print and color the text of debugging! Ritenetelo a deepening of the first program "Hello World!", In the end it is always easy printing ...
remember that the "Hello World! print this written in a predetermined position using the predetermined color (white). From that source and use the same Makefile to compile.




To use these features we must add the library " pspdebug.h .



changed positions!

If you remember, we used the "pspDebugScreenPrintf (" Hello World! ")" To print text on the screen. And if we wanted to change the position of the writing?
Default is to put at the top left ...
Then we use the first function:



pspDebugScreenSetXY (int x, int y);



and set the value of x to move the text horizontally and vertically to move the y ( plus the value of x is higher and the message is moved to the right, plus the value of y is higher and the message is printed below, remember not to go too high or low otherwise die outside the visible screen ).
After setting the position, we use the classic function that this time the press in the position we have chosen:



pspDebugScreenPrintf ("Hello World!") ;





color the text!

Now let us have the color of the writing ...
For convenience we set a macro that transforms the color we give to the program in hexadecimal code (the same color coding that exists in the HTML). In short, we make sure that they can change color by increasing or decreasing value of the three primary colors on the PC (R G B, red ( Red), green (Green ), blue (Blue )).
Then in the code (before the function "main") write:


# define RGB (r, g, b) ((r) <<8)|((b)<<16))


pspDebugScreenSetTextColor (RGB (red, yellow, blue));


The values \u200b\u200bof "red", "yellow" and "blue" can range from 0 to 255. Remember that if all three values \u200b\u200bare set to 0 you will have the color black. If all 3 are set to 255 you will have the opposite, that is WHITE. Appropriately setting these three parameters can be obtained all the colors you want (staying in the 32-bit!) Now after setting the color we use the classic function to print, only this time we will print in color set:





pspDebugScreenPrintf ("Hello World!") ;



color the background of the text!



Now we color the text, but there is a 'latest gem to make a more colorful print! If you notice you can print in any color you want, but the background is always black! And if we want to color the background on which we print the text? In short, if you set the color black in writing, you see a bat! In fact the screen is black and white writing on black is not a smart thing, but if we want to write using the color black because we like? We can color the line under the word. What to do? I tell you!


First we must enable this option by writing:

pspDebugScreenEnableBackColor (1);





If we want to disable it, call it by passing the value 0 instead of 1.



After we set the color for that line (same argument as before to the colors):




pspDebugScreenSetBackColor ( RGB (red, yellow, blue)

)

Finally print the words:




pspDebugScreenPrintf ("Hello World!")
;






premise that these are just some of the prettiest that I seemed appropriate to report. In fact there are many to manage printing and debugging are all located in the library "
pspdebug.h
.

remind everyone that these three features can be used together! Just put them before printing the text!

I hope I was clear and helpful at all with this little time on her ' argument debug print ...

0 comments:

Post a Comment