-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCenterText.lib.nxc
44 lines (42 loc) · 917 Bytes
/
CenterText.lib.nxc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* CenterText.Lib.nxc
*
* Centers text on the NXT screen
*
* @author Shea Bunge <http://robotics.bungeshea.com>
*/
/**
* CenterText
*
* Takes an input string and returns the x position
* to use to display the string on the NXT screen
*
* @param const string text
* @return int len
*
* @author Shea Bunge <http://robotics.bungeshea.com>
*/
int CenterText( const string text ) {
int len = StrLen(text);
len = (len * 5);
len = (100 - len);
len = (len / 2);
len = (len - 5);
return len;
}
/**
* CenterTextOut
*
* Displays a string, centered, on the NXT screen
*
* @param int y
* @param string text
* @param unsigned long options
* @return char result
*
* @author Shea Bunge <http://robotics.bungeshea.com>
*/
char CenterTextOut( int y, string text, unsigned long options = DRAW_OPT_NORMAL ) {
int len = CenterText(text);
return TextOut( len, y, text, options );
}