Print
Prints the given (multi-lined) text to the screen at the given coordinates. Note that the y-coordinate is the y-coordinate of the baseline of the first text line, not the top position of the text (changed from the previous version)! All coordinates are in pixels. Note that you can print multi-lined text such that the end of a line is marked with an endline character (\n). Also notice that for performance reasons the function takes a reference to the printed text. This means that you have to construct a text variable first and then pass it to this function. OpenLayer contains a function ToString that converts a variable (number, for example) to a string so that it can be passed to the Print -function. See the examples of how to do this. Examples TextRenderer myTextRenderer(...);
// Print the text Hello World! to the screen such that the // // top-left corner of the text is positioned at // // x = 200 and y-coodinate of the baseline = 110 // String message = "Hello World!"; myTextRenderer.Print( message, 200, 110 ); // Print a multi-lined message at the same position in the screen // String message = "First line\nSecond line\nThird line"; myTextRenderer.Print( message, 200, 110 ); // Print a number in the screen // int number = 500; String message = ToString( number ); myTextRenderer.Print( message, 200, 110 ); // Print a some text and two numbers in the screen // int number1 = 500; float number2 = 750.5; String message = "The first number is " + ToString( number1 ) + " and the second number is " + ToString( number2 ); // message is: The first number is 500 and the second number is 750.5 // myTextRenderer.Print( message, 200, 110 ); Other functions of the class TextRenderer
Questions about Print? Click here. | ||||||||||||||||||||||||||||||||||