MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / getPositionForCharNumber

Function getPositionForCharNumber

deps/SDL2/Xcode-iOS/Demos/src/keyboard.c:133–150  ·  view source on GitHub ↗

This function returns and x,y position for a given character number. It is used for positioning each character of text */

Source from the content-addressed store, hash-verified

131 It is used for positioning each character of text
132*/
133void
134getPositionForCharNumber(int n, int *x, int *y)
135{
136 int renderW, renderH;
137 SDL_RenderGetLogicalSize(renderer, &renderW, &renderH);
138
139 int x_padding = 16; /* padding space on left and right side of screen */
140 int y_padding = 32; /* padding space at top of screen */
141 /* figure out the number of characters that can fit horizontally across the screen */
142 int max_x_chars = (renderW - 2 * x_padding) / GLYPH_SIZE_SCREEN;
143 int line_separation = 5; /* pixels between each line */
144 *x = (n % max_x_chars) * GLYPH_SIZE_SCREEN + x_padding;
145#ifdef TEST_INPUT_RECT
146 *y = renderH - GLYPH_SIZE_SCREEN;
147#else
148 *y = (n / max_x_chars) * (GLYPH_SIZE_SCREEN + line_separation) + y_padding;
149#endif
150}
151
152void
153drawGlyph(int glyph, int positionIndex)

Callers 1

drawGlyphFunction · 0.85

Calls 1

SDL_RenderGetLogicalSizeFunction · 0.85

Tested by

no test coverage detected