1#ifndef RAYLIB_CPP_INCLUDE_TEXT_HPP_
2#define RAYLIB_CPP_INCLUDE_TEXT_HPP_
8#include "./RaylibException.hpp"
9#include "./raylib-cpp-utils.hpp"
10#include "./RadiansDegrees.hpp"
11#include "./Vector2.hpp"
54 const std::string_view
text =
"",
56 const ::Color&
color = WHITE,
57 const ::Font&
font = ::GetFontDefault(),
78 const std::string_view
text =
"",
81 const ::Color&
color = WHITE) :
106 void Draw(
int posX,
int posY)
const {
109 { static_cast<float>(posX), static_cast<float>(posY) },
120 void Draw(const ::Vector2& position,
Degree rotation, const ::Vector2& origin = {0, 0})
const {
128 return ::MeasureText(
text.c_str(),
static_cast<int>(
fontSize));
138 Text& operator=(
const Text& other) {
139 if (
this == &other) {
158 const std::string_view
text,
162 const ::Color&
color) {
172 const std::string_view
text,
173 const ::Vector2& pos,
175 const ::Color&
color) {
176 ::DrawText(
text.data(),
static_cast<int>(pos.x),
static_cast<int>(pos.y),
fontSize,
color);
186 const std::string_view
text,
187 const ::Vector2& position,
190 const ::Color&
color) {
201 const std::string_view
text,
202 const ::Vector2& position,
203 const ::Vector2& origin,
207 const ::Color&
color) {
Degree type (allows automatic worry free conversion between radians and degrees)
Font type, includes texture and charSet array data.
float fontSize
The size of the text.
static void Draw(const std::string_view text, const int posX, const int posY, const int fontSize, const ::Color &color)
Draw text using font and color.
Vector2 MeasureEx() const
Measure string size for Font.
static void Draw(const std::string_view text, const ::Vector2 &pos, const int fontSize, const ::Color &color)
Draw text using font and color, with position defined as Vector2.
int Measure() const
Measure string width for default font.
static void Draw(const ::Font &font, const std::string_view text, const ::Vector2 &position, const ::Vector2 &origin, const Degree rotation, const float fontSize, const float spacing, const ::Color &color)
Draw text using font, color, position, origin, font size and spacing.
float spacing
The character spacing for the text.
void Draw(const ::Vector2 &position, Degree rotation, const ::Vector2 &origin={0, 0}) const
Draw text using Font and pro parameters (rotation).
static void Draw(const ::Font &font, const std::string_view text, const ::Vector2 &position, const float fontSize, const float spacing, const ::Color &color)
Draw text using font, color, position, font size and spacing.
::Font font
The internal raylib font to use for the text.
Text(const std::string_view text="", float fontSize=10, const ::Color &color=WHITE, const ::Font &font=::GetFontDefault(), float spacing=0)
Initializes a new Text object.
Text(const ::Font &font, const std::string_view text="", float fontSize=10, float spacing=0, const ::Color &color=WHITE)
Initializes a new Text object with a custom font.
::Color color
The color of the text.
std::string text
The internal text.
void Draw(int posX, int posY) const
Draw text with values in class.
void Draw(const ::Vector2 &position) const
Draw text with values in class.