doodle  0.2
Intended to support teaching C++, doodle is a simple library that helps make a window and makes it easy to do some drawing.
Functions | Variables
Events

Functions

int doodle::get_mouse_x () noexcept
 Get the mouse's X position relative to the currently set doodle::FrameOfReference. More...
 
int doodle::get_mouse_y () noexcept
 Get the mouse's Y position relative to the currently set doodle::FrameOfReference. More...
 
int doodle::get_previous_mouse_x () noexcept
 Get the previous mouse's X position relative to the currently set doodle::FrameOfReference. More...
 
int doodle::get_previous_mouse_y () noexcept
 Get the previous mouse's Y position relative to the currently set doodle::FrameOfReference. More...
 
void doodle::set_callback_key_pressed (std::function< void(KeyboardButtons)> &&callback) noexcept
 The provided callback function is called once every time a key is pressed. More...
 
void doodle::set_callback_key_released (std::function< void(KeyboardButtons)> &&callback) noexcept
 The provided callback function is called once every time a key is released. More...
 
void doodle::set_callback_mouse_moved (std::function< void(int, int)> &&callback) noexcept
 The provided callback function is called every time the mouse moves. More...
 
void doodle::set_callback_mouse_pressed (std::function< void(MouseButtons)> &&callback) noexcept
 The provided callback is called whenever a mouse button is pressed. More...
 
void doodle::set_callback_mouse_released (std::function< void(MouseButtons)> &&callback) noexcept
 The provided callback is called whenever a mouse button is released. More...
 
void doodle::set_callback_mouse_wheel (std::function< void(int)> &&callback) noexcept
 The provided callback is called whenever the mouse wheel is scrolled. More...
 
EVENT_HOOK void on_key_pressed (doodle::KeyboardButtons button)
 The declaration of the optional on_key_pressed function to implement in your doodle program. More...
 
EVENT_HOOK void on_key_released (doodle::KeyboardButtons button)
 The declaration of the optional on_key_released function to implement in your doodle program. More...
 
EVENT_HOOK void on_mouse_moved (int mouse_x, int mouse_y)
 The declaration of the optional on_mouse_moved function to implement in your doodle program. More...
 
EVENT_HOOK void on_mouse_pressed (doodle::MouseButtons button)
 The declaration of the optional on_mouse_pressed function to implement in your doodle program. More...
 
EVENT_HOOK void on_mouse_released (doodle::MouseButtons button)
 The declaration of the optional on_mouse_released function to implement in your doodle program. More...
 
EVENT_HOOK void on_mouse_wheel (int scroll_amount)
 The declaration of the optional on_mouse_wheel function to implement in your doodle program. More...
 

Variables

bool doodle::MouseIsPressed
 The boolean system variable MouseIsPressed is true if the mouse is pressed and false if not. More...
 
bool doodle::KeyIsPressed
 The boolean system variable KeyIsPressed is true if any key is pressed and false if no keys are pressed. More...
 
KeyboardButtons doodle::Key
 The system variable key always contains the value of the most recent key on the keyboard that was typed. More...
 
MouseButtons doodle::MouseButton
 doodle automatically tracks if the mouse button is pressed and which button is pressed. The value of the system variable MouseButton is either LEFT, RIGHT, or CENTER depending on which button was pressed last. More...
 

Detailed Description

Function Documentation

◆ get_mouse_x()

int doodle::get_mouse_x ( )
noexcept

Get the mouse's X position relative to the currently set doodle::FrameOfReference.

Returns
the current horizontal position of the mouse, relative to the currently set doodle::FrameOfReference
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
clear_background(244, 248, 252);
const int mouseX = get_mouse_x();
draw_line(mouseX, Height / 2.0, mouseX, -Height / 2.0);
}
return 0;
}
void clear_background() noexcept
Clear the background to black.
bool create_window() noexcept
Create a default window.
bool is_window_closed() noexcept
Is the window closed?
int Height
System variable that stores the height of the drawing canvas. This value is set by the desired_height...
void update_window() noexcept
Update the doodle application.
int get_mouse_x() noexcept
Get the mouse's X position relative to the currently set doodle::FrameOfReference.
void draw_line(double x1, double y1, double x2, double y2) noexcept
Draws a line (a direct path between two points) to the screen.
Definition: angle.hpp:11

◆ get_mouse_y()

int doodle::get_mouse_y ( )
noexcept

Get the mouse's Y position relative to the currently set doodle::FrameOfReference.

Returns
the current vertical position of the mouse, relative to the currently set doodle::FrameOfReference
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
clear_background(244, 248, 252);
const int mouseY = get_mouse_y();
draw_line(-Width / 2.0, mouseY, Width / 2.0, mouseY);
}
return 0;
}
int Width
System variable that stores the width of the drawing canvas. This value is set by the desired_width p...
int get_mouse_y() noexcept
Get the mouse's Y position relative to the currently set doodle::FrameOfReference.

◆ get_previous_mouse_x()

int doodle::get_previous_mouse_x ( )
noexcept

Get the previous mouse's X position relative to the currently set doodle::FrameOfReference.

Returns
the previous horizontal position of the mouse, relative to the currently set doodle::FrameOfReference
#include <thread>
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
clear_background(244, 248, 252);
const int mouseX = get_mouse_x();
const int mouseY = get_mouse_y();
const int prevMouseX = get_previous_mouse_x();
const int prevMouseY = get_previous_mouse_y();
draw_line(mouseX, mouseY, prevMouseX, prevMouseY);
// slow down frame rate to make it more visible
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
}
return 0;
}
int get_previous_mouse_x() noexcept
Get the previous mouse's X position relative to the currently set doodle::FrameOfReference.
int get_previous_mouse_y() noexcept
Get the previous mouse's Y position relative to the currently set doodle::FrameOfReference.

◆ get_previous_mouse_y()

int doodle::get_previous_mouse_y ( )
noexcept

Get the previous mouse's Y position relative to the currently set doodle::FrameOfReference.

Returns
Get the previous mouse's Y position relative to the currently set doodle::FrameOfReference
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
clear_background(237, 34, 93);
draw_line(-Width / 2.0 + 20, get_mouse_y(), Width / 2.0 - 20.0, get_previous_mouse_y());
}
return 0;
}
void set_fill_color(HexColor color) noexcept
Sets the color used to fill shapes to the specified HexColor.
void set_rectangle_mode(RectMode mode) noexcept
Modifies the location from which rectangles are drawn by changing the way in which parameters given t...
@ Center
RectMode::CENTER interprets the first two parameters of draw_rectangle() as the shape's center point.

◆ on_key_pressed()

EVENT_HOOK void on_key_pressed ( doodle::KeyboardButtons  button)

The declaration of the optional on_key_pressed function to implement in your doodle program.

If you define the function definition of this function then it will be called when a keyboard button is pressed.

Parameters
buttonwhich button is being pressed
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
}
return 0;
}
{
if (button < KeyboardButtons::A || button > KeyboardButtons::Z)
{
clear_background(220); // if it's not a letter clear the screen
return;
}
const auto r = random(0, 256);
const auto g = random(0, 256);
const auto b = random(0, 256);
set_fill_color(r, g, b);
const double rectWidth = Width / 4.0;
const double key = (static_cast<double>(button) - static_cast<double>(KeyboardButtons::A));
const double x = key / (25.0) * (Width - rectWidth);
draw_rectangle(x, 0, rectWidth, Height * 1.0);
}
EVENT_HOOK void on_key_pressed(doodle::KeyboardButtons button)
The declaration of the optional on_key_pressed function to implement in your doodle program.
void draw_rectangle(double x, double y, double width, double height=0) noexcept
Draws a rectangle to the screen.
void set_frame_of_reference(FrameOfReference frame_of_reference) noexcept
Change the coordinate system you would like to use when describing your primitives.
@ RightHanded_OriginBottomLeft
The Origin (0,0) is always in the bottom left of the screen. Positive x goes to the right and Positiv...
double random(double min_inclusive, double max_exclusive) noexcept
Return a random floating-point number within the range [min,max)
KeyboardButtons
Definition: input.hpp:26

◆ on_key_released()

EVENT_HOOK void on_key_released ( doodle::KeyboardButtons  button)

The declaration of the optional on_key_released function to implement in your doodle program.

If you define the function definition of this function then it will be called when a keyboard button is released.

Parameters
buttonwhich button was released
using namespace doodle;
double grey{0};
{
if (grey == 0)
grey = 255;
else
grey = 0;
if (button == KeyboardButtons::Escape)
}
int main(void)
{
create_window(480, 360);
grey = 0;
while (!is_window_closed())
{
draw_rectangle(0, 0, Width * 0.6, Height * 0.6);
}
return 0;
}
void close_window() noexcept
Programmatically close the window.
EVENT_HOOK void on_key_released(doodle::KeyboardButtons button)
The declaration of the optional on_key_released function to implement in your doodle program.
@ Escape
The Escape key.

◆ on_mouse_moved()

EVENT_HOOK void on_mouse_moved ( int  mouse_x,
int  mouse_y 
)

The declaration of the optional on_mouse_moved function to implement in your doodle program.

If you define the function definition of this function then it will be called whenever the mouse moves to a new position.

Parameters
mouse_xmouse x position relative to the current doodle::FrameOfReference
mouse_ymouse y position relative to the current doodle::FrameOfReference
using namespace doodle;
double angle{0.0};
double grey{0};
double x{0.0};
double y{0.0};
void on_mouse_moved(int mouse_x, int mouse_y)
{
angle += to_radians(3.0);
grey = 255 * (std::sin(angle) * 0.5 + 0.5);
x = mouse_x;
y = mouse_y;
}
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
draw_rectangle(x, y, Width * 0.4, Height * 0.4);
}
return 0;
}
constexpr double to_radians(double angle_in_degrees) noexcept
Converts a degree measurement to its corresponding value in radians. Radians and degrees are two ways...
Definition: angle.hpp:78
EVENT_HOOK void on_mouse_moved(int mouse_x, int mouse_y)
The declaration of the optional on_mouse_moved function to implement in your doodle program.

◆ on_mouse_pressed()

EVENT_HOOK void on_mouse_pressed ( doodle::MouseButtons  button)

The declaration of the optional on_mouse_pressed function to implement in your doodle program.

If you define the function definition of this function then it will be called whenever a mouse button is pressed.

Parameters
buttonwhich button is being pressed
using namespace doodle;
bool shouldFollowMouse = false;
{
if (button == MouseButtons::Left)
shouldFollowMouse = true;
}
{
if (button == MouseButtons::Left)
shouldFollowMouse = false;
}
int main(void)
{
double x{0.0};
double y{0.0};
create_window(480, 360);
while (!is_window_closed())
{
if (shouldFollowMouse)
{
const double easing = 3.0 * DeltaTime;
x += easing * (get_mouse_x() - x);
y += easing * (get_mouse_y() - y);
}
clear_background(237, 34, 93);
draw_ellipse(x, y, Width * 0.1);
}
return 0;
}
double DeltaTime
The system variable DeltaTime contains the time difference between the beginning of the previous fram...
EVENT_HOOK void on_mouse_released(doodle::MouseButtons button)
The declaration of the optional on_mouse_released function to implement in your doodle program.
EVENT_HOOK void on_mouse_pressed(doodle::MouseButtons button)
The declaration of the optional on_mouse_pressed function to implement in your doodle program.
void draw_ellipse(double x, double y, double width, double height=0) noexcept
Draws an ellipse (oval) to the screen.
MouseButtons
Definition: input.hpp:17
@ Left
Left Mouse Button.

◆ on_mouse_released()

EVENT_HOOK void on_mouse_released ( doodle::MouseButtons  button)

The declaration of the optional on_mouse_released function to implement in your doodle program.

If you define the function definition of this function then it will be called whenever a mouse button was released.

Parameters
buttonwhich button was released
using namespace doodle;
bool shouldFollowMouse = false;
{
if (button == MouseButtons::Left)
shouldFollowMouse = true;
}
{
if (button == MouseButtons::Left)
shouldFollowMouse = false;
}
int main(void)
{
double x{0.0};
double y{0.0};
create_window(480, 360);
while (!is_window_closed())
{
if (shouldFollowMouse)
{
const double easing = 3.0 * DeltaTime;
x += easing * (get_mouse_x() - x);
y += easing * (get_mouse_y() - y);
}
clear_background(237, 34, 93);
draw_ellipse(x, y, Width * 0.1);
}
return 0;
}

◆ on_mouse_wheel()

EVENT_HOOK void on_mouse_wheel ( int  scroll_amount)

The declaration of the optional on_mouse_wheel function to implement in your doodle program.

If you define the function definition of this function then it will be called whenever the mouse wheel scrolls.

Parameters
scroll_amountPositive for scroll up and negative for scroll down.
using namespace doodle;
double y{0.0};
void on_mouse_wheel(int scroll_amount) { y += scroll_amount * 2.0; }
int main(void)
{
create_window(480, 360);
set_fill_color(HexColor{0xc8d3d8ff});
while (!is_window_closed())
{
clear_background(HexColor{0xf7fcfdff});
draw_ellipse(0, y, Width * 0.3);
}
return 0;
}
EVENT_HOOK void on_mouse_wheel(int scroll_amount)
The declaration of the optional on_mouse_wheel function to implement in your doodle program.

◆ set_callback_key_pressed()

void doodle::set_callback_key_pressed ( std::function< void(KeyboardButtons)> &&  callback)
noexcept

The provided callback function is called once every time a key is pressed.

It takes in a std::function with a signature of something that returns nothing and takes in a doodle::KeyboardButtons. Something like

void keyPressed(doodle::KeyboardButtons button);
Parameters
callbackwhat to call when a key is pressed
using namespace doodle;
void keyPressed(KeyboardButtons button);
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
}
return 0;
}
void keyPressed(KeyboardButtons button)
{
if (button < KeyboardButtons::A || button > KeyboardButtons::Z)
{
clear_background(220); // if it's not a letter clear the screen
return;
}
const auto r = random(0, 256);
const auto g = random(0, 256);
const auto b = random(0, 256);
set_fill_color(r, g, b);
const double rectWidth = Width / 4.0;
const double key = (static_cast<double>(button) - static_cast<double>(KeyboardButtons::A));
const double x = key / (25.0) * (Width - rectWidth);
draw_rectangle(x, 0, rectWidth, Height * 1.0);
}
void set_callback_key_pressed(std::function< void(KeyboardButtons)> &&callback) noexcept
The provided callback function is called once every time a key is pressed.

◆ set_callback_key_released()

void doodle::set_callback_key_released ( std::function< void(KeyboardButtons)> &&  callback)
noexcept

The provided callback function is called once every time a key is released.

It takes in a std::function with a signature of something that returns nothing and takes in a doodle::KeyboardButtons. Something like

void keyReleased(doodle::KeyboardButtons button);
Parameters
callbackwhat to call when a key is released
using namespace doodle;
class Logic
{
double grey{0.0};
public:
void Setup() noexcept
{
create_window(480, 360);
grey = 0;
set_callback_key_released([this](KeyboardButtons b) { OnKeyReleased(b); });
}
void Run() const noexcept
{
while (!is_window_closed())
{
Draw();
}
}
void Draw() const noexcept
{
draw_rectangle(0, 0, Width * 0.6, Height * 0.6);
}
void OnKeyReleased(KeyboardButtons button) noexcept
{
if (grey == 0)
grey = 255;
else
grey = 0;
if (button == KeyboardButtons::Escape)
}
};
int main(void)
{
Logic logic{};
logic.Setup();
logic.Run();
return 0;
}
void set_callback_key_released(std::function< void(KeyboardButtons)> &&callback) noexcept
The provided callback function is called once every time a key is released.

◆ set_callback_mouse_moved()

void doodle::set_callback_mouse_moved ( std::function< void(int, int)> &&  callback)
noexcept

The provided callback function is called every time the mouse moves.

It takes in a std::function with a signature of something that returns nothing and takes in a two integers. Something like

void mouseMoved(int mouse_x, int mouse_y);
Parameters
callbackwhat to call when the mouse moves
using namespace doodle;
class Logic
{
double angle{0.0};
double grey{0};
double x{0.0};
double y{0.0};
public:
void Setup() noexcept
{
create_window(480, 360);
set_callback_mouse_moved([this](int x, int y) { OnMouseMoved(x, y); });
}
void Run() const noexcept
{
while (!is_window_closed())
{
Draw();
}
}
void Draw() const noexcept
{
draw_rectangle(x, y, Width * 0.4, Height * 0.4);
}
void OnMouseMoved(int mouse_x, int mouse_y) noexcept
{
angle += to_radians(3.0);
grey = 255 * (std::sin(angle) * 0.5 + 0.5);
x = mouse_x;
y = mouse_y;
}
};
int main(void)
{
Logic logic{};
logic.Setup();
logic.Run();
return 0;
}
void set_callback_mouse_moved(std::function< void(int, int)> &&callback) noexcept
The provided callback function is called every time the mouse moves.

◆ set_callback_mouse_pressed()

void doodle::set_callback_mouse_pressed ( std::function< void(MouseButtons)> &&  callback)
noexcept

The provided callback is called whenever a mouse button is pressed.

It takes in a std::function with a signature of something that returns nothing and takes in a doodle::MouseButtons. Something like

void mousePressed(doodle::MouseButtons button);
Parameters
callbackwhat to call when the mouse is pressed
using namespace doodle;
class Logic
{
double x{0.0};
double y{0.0};
bool shouldFollowMouse = false;
public:
void Setup() noexcept
{
create_window(480, 360);
set_callback_mouse_pressed([this](MouseButtons b) { OnMousePressed(b); });
set_callback_mouse_released([this](MouseButtons b) { OnMouseReleased(b); });
}
void Run() noexcept
{
while (!is_window_closed())
{
if (shouldFollowMouse)
{
const double easing = 3.0 * DeltaTime;
x += easing * (get_mouse_x() - x);
y += easing * (get_mouse_y() - y);
}
Draw();
}
}
void Draw() const noexcept
{
clear_background(237, 34, 93);
draw_ellipse(x, y, Width * 0.1);
}
void OnMousePressed(MouseButtons button) noexcept
{
if (button == MouseButtons::Left)
shouldFollowMouse = true;
}
void OnMouseReleased(MouseButtons button) noexcept
{
if (button == MouseButtons::Left)
shouldFollowMouse = false;
}
};
int main(void)
{
Logic logic{};
logic.Setup();
logic.Run();
return 0;
}
void set_callback_mouse_pressed(std::function< void(MouseButtons)> &&callback) noexcept
The provided callback is called whenever a mouse button is pressed.
void set_callback_mouse_released(std::function< void(MouseButtons)> &&callback) noexcept
The provided callback is called whenever a mouse button is released.

◆ set_callback_mouse_released()

void doodle::set_callback_mouse_released ( std::function< void(MouseButtons)> &&  callback)
noexcept

The provided callback is called whenever a mouse button is released.

It takes in a std::function with a signature of something that returns nothing and takes in a doodle::MouseButtons. Something like

void mouseReleased(doodle::MouseButtons button);
Parameters
callbackwhat to call when the mouse is released
using namespace doodle;
class Logic
{
double x{0.0};
double y{0.0};
bool shouldFollowMouse = false;
public:
void Setup() noexcept
{
create_window(480, 360);
set_callback_mouse_pressed([this](MouseButtons b) { OnMousePressed(b); });
set_callback_mouse_released([this](MouseButtons b) { OnMouseReleased(b); });
}
void Run() noexcept
{
while (!is_window_closed())
{
if (shouldFollowMouse)
{
const double easing = 3.0 * DeltaTime;
x += easing * (get_mouse_x() - x);
y += easing * (get_mouse_y() - y);
}
Draw();
}
}
void Draw() const noexcept
{
clear_background(237, 34, 93);
draw_ellipse(x, y, Width * 0.1);
}
void OnMousePressed(MouseButtons button) noexcept
{
if (button == MouseButtons::Left)
shouldFollowMouse = true;
}
void OnMouseReleased(MouseButtons button) noexcept
{
if (button == MouseButtons::Left)
shouldFollowMouse = false;
}
};
int main(void)
{
Logic logic{};
logic.Setup();
logic.Run();
return 0;
}

◆ set_callback_mouse_wheel()

void doodle::set_callback_mouse_wheel ( std::function< void(int)> &&  callback)
noexcept

The provided callback is called whenever the mouse wheel is scrolled.

It takes in a std::function with a signature of something that returns nothing and takes in an integer. Something like

void mouseWheel(int scroll_amount);
Parameters
callbackwhat to call when the mouse wheel is scrolled
using namespace doodle;
class Logic
{
double y{0.0};
public:
void Setup() noexcept
{
create_window(480, 360);
set_fill_color(HexColor{0xc8d3d8ff});
set_callback_mouse_wheel([this](int s) { OnMouseWheel(s); });
}
void Run() const noexcept
{
while (!is_window_closed())
{
Draw();
}
}
void Draw() const noexcept
{
clear_background(HexColor{0xf7fcfdff});
draw_ellipse(0, y, Width * 0.3);
}
void OnMouseWheel(int scroll_amount) noexcept { y += scroll_amount * 2.0; }
};
int main(void)
{
Logic logic{};
logic.Setup();
logic.Run();
return 0;
}
void set_callback_mouse_wheel(std::function< void(int)> &&callback) noexcept
The provided callback is called whenever the mouse wheel is scrolled.

Variable Documentation

◆ Key

KeyboardButtons doodle::Key
extern

The system variable key always contains the value of the most recent key on the keyboard that was typed.

using namespace doodle;
int main(void)
{
create_window(480, 360);
set_fill_color(245, 123, 158);
while (!is_window_closed())
{
draw_text(to_string(Key), -60.0, -30.0);
}
return 0;
}
bool KeyIsPressed
The boolean system variable KeyIsPressed is true if any key is pressed and false if no keys are press...
KeyboardButtons Key
The system variable key always contains the value of the most recent key on the keyboard that was typ...
void draw_text(const std::wstring &str, double x, double y) noexcept
Draws wide character based text to the screen.
std::string to_string(MouseButtons button) noexcept
Convert MouseButtons enum to std::string.

◆ KeyIsPressed

bool doodle::KeyIsPressed
extern

The boolean system variable KeyIsPressed is true if any key is pressed and false if no keys are pressed.

#include <string>
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
{
}
else
{
}
draw_rectangle(0, 0, Width / 2.0, Height / 2.0);
using namespace std::string_literals;
draw_text("Pressed: "s + ((KeyIsPressed) ? "true"s : "false"s), 5, 0);
}
return 0;
}
@ RightHanded_OriginCenter
The Origin (0,0) is always in the center of the screen. Positive x goes to the right and Positive y g...

◆ MouseButton

MouseButtons doodle::MouseButton
extern

doodle automatically tracks if the mouse button is pressed and which button is pressed. The value of the system variable MouseButton is either LEFT, RIGHT, or CENTER depending on which button was pressed last.

#include <cmath>
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
clear_background(237, 34, 93);
switch (MouseButton)
{
case MouseButtons::Left: draw_ellipse(0, 0, Width / 2.0, Height / 2.0); break;
{
const double length = 0.5 * std::sqrt((Width * Width) / 4.0 + (Height * Height) / 4.0);
draw_triangle(0, length, -0.866 * length, -0.5 * length, 0.866 * length, -0.5 * length);
}
break;
case MouseButtons::Right: draw_rectangle(0, 0, Width / 2.0, Height / 2.0); break;
default: break;
}
}
return 0;
}
MouseButtons MouseButton
doodle automatically tracks if the mouse button is pressed and which button is pressed....
void draw_triangle(double x1, double y1, double x2, double y2, double x3, double y3) noexcept
Draw a triangle to the screen.
@ Right
Right Mouse Button.
@ Middle
Middle Mouse Button.

◆ MouseIsPressed

bool doodle::MouseIsPressed
extern

The boolean system variable MouseIsPressed is true if the mouse is pressed and false if not.

#include <string>
using namespace doodle;
int main(void)
{
create_window(480, 360);
while (!is_window_closed())
{
clear_background(237, 34, 93);
{
draw_ellipse(0, 0, Width / 2.0, Height / 2.0);
}
else
{
draw_rectangle(0, 0, Width / 2.0, Height / 2.0);
}
using namespace std::string_literals;
draw_text("Pressed: "s + ((MouseIsPressed) ? "true"s : "false"s), 5, 0);
}
return 0;
}
bool MouseIsPressed
The boolean system variable MouseIsPressed is true if the mouse is pressed and false if not.