| 339 | } |
| 340 | |
| 341 | Point Bitmap::TextDraw(Rect const& rect, int color, std::string_view text, Text::Alignment align) { |
| 342 | switch (align) { |
| 343 | case Text::AlignLeft: |
| 344 | return TextDraw(rect.x, rect.y, color, text); |
| 345 | break; |
| 346 | case Text::AlignCenter: { |
| 347 | auto f = font ? font : Font::Default(); |
| 348 | Rect text_rect = Text::GetSize(*f, text); |
| 349 | int dx = rect.x + (rect.width - text_rect.width) / 2; |
| 350 | return TextDraw(dx, rect.y, color, text); |
| 351 | break; |
| 352 | } |
| 353 | case Text::AlignRight: { |
| 354 | auto f = font ? font : Font::Default(); |
| 355 | Rect text_rect = Text::GetSize(*f, text); |
| 356 | int dx = rect.x + rect.width - text_rect.width; |
| 357 | return TextDraw(dx, rect.y, color, text); |
| 358 | break; |
| 359 | } |
| 360 | default: assert(false); |
| 361 | } |
| 362 | |
| 363 | return {}; |
| 364 | } |
| 365 | |
| 366 | Point Bitmap::TextDraw(int x, int y, int color, std::string_view text, Text::Alignment align) { |
| 367 | auto f = font ? font : Font::Default(); |
no outgoing calls
no test coverage detected