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.
Classes | Enumerations | Functions | Variables
doodle Namespace Reference

Classes

class  Color
 Color is a color represented with four unsigned bytes. More...
 
class  HexColor
 This is a helper class to easily represent an RGBA color as an int with hexadecimal notation. More...
 
class  Image
 Image class to store a 2D array of RGBA colors. Also manages an image on the Graphics Card. More...
 

Enumerations

enum class  EllipseMode { Center , Corner }
 With set_ellipse_mode(), modifies the location from which ellipses are drawn by changing the way in which parameters given to draw_ellipse() are interpreted. More...
 
enum class  RectMode { Corner , Center }
 With set_rectangle_mode(), modifies the location from which rectangles are drawn by changing the way in which parameters given to draw_rectangle() are interpreted. More...
 
enum class  FrameOfReference { RightHanded_OriginCenter , RightHanded_OriginBottomLeft , LeftHanded_OriginTopLeft }
 Used to define the coordinate system you would like to reference. More...
 
enum class  MouseButtons { None , Left , Middle , Right , Count }
 
enum class  KeyboardButtons {
  None , _0 , _1 , _2 , _3 , _4 , _5 , _6 , _7 , _8 , _9 , A , B , C , D , E , F , G , H , I ,
  J , K , L , M , N , O , P , Q , R , S , T , U , V , W , X , Y , Z , NumPad_0 , NumPad_1 , NumPad_2 ,
  NumPad_3 , NumPad_4 , NumPad_5 , NumPad_6 , NumPad_7 , NumPad_8 , NumPad_9 , Escape , Control , Shift , CapsLock , LeftSystem , RightSystem , Menu , LeftBracket , RightBracket , Semicolon , Comma , Period , Quote ,
  Slash , Backslash , Tilde , Equal , Hyphen , Space , Enter , Backspace , Tab , PageUp , PageDown , End , Home , PrintScreen , Insert , Delete , Add , Subtract , Multiply , Divide ,
  Left , Right , Up , Down , F1 , F2 , F3 , F4 , F5 , F6 , F7 , F8 , F9 , Pause , Count
}
 

Functions

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 of measuring the same thing. There are 360 degrees in a circle and \(2\pi\) radians in a circle. For example, \(90^{\circ}=\frac{\pi}{2}=1.5707964\). More...
 
constexpr double to_degrees (double angle_in_radians) noexcept
 Converts a radian measurement to its corresponding value in degrees. Radians and degrees are two ways of measuring the same thing. There are 360 degrees in a circle and \(2\pi\) radians in a circle. For example, \(90^{\circ}=\frac{\pi}{2}=1.5707964\). More...
 
void clear_background () noexcept
 Clear the background to black. More...
 
void clear_background (HexColor color) noexcept
 Clear the background to the specified HexColor. More...
 
void clear_background (Color color) noexcept
 Clear the background to the specified Color. More...
 
void clear_background (double grey, double alpha=255) noexcept
 Clear the background to a grey color. More...
 
void clear_background (double red, double green, double blue, double alpha=255) noexcept
 Clear the background to a specified RGBA color. More...
 
void set_fill_color (HexColor color) noexcept
 Sets the color used to fill shapes to the specified HexColor. More...
 
void set_fill_color (Color color) noexcept
 Sets the color used to fill shapes to the specified Color. More...
 
void set_fill_color (double grey, double alpha=255) noexcept
 Sets the color used to fill shapes to a grey. More...
 
void set_fill_color (double red, double green, double blue, double alpha=255) noexcept
 Sets the color used to fill shapes to the specified RGBA values. More...
 
void no_fill () noexcept
 Disables filling geometry. More...
 
void set_outline_color (HexColor color) noexcept
 Set the outline and lines of shapes to the specified HexColor. More...
 
void set_outline_color (Color color) noexcept
 Set the outline and lines of shapes to the specified Color. More...
 
void set_outline_color (double grey, double alpha=255) noexcept
 Set the outline and lines of shapes to a grey color. More...
 
void set_outline_color (double red, double green, double blue, double alpha=255) noexcept
 Set the outline and lines of shapes to an RGBA color. More...
 
void no_outline ()
 Disables drawing the outline. More...
 
void draw_ellipse (double x, double y, double width, double height=0) noexcept
 Draws an ellipse (oval) to the screen. More...
 
void draw_line (double x1, double y1, double x2, double y2) noexcept
 Draws a line (a direct path between two points) to the screen. More...
 
void draw_quad (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) noexcept
 Draw a quad. More...
 
void draw_rectangle (double x, double y, double width, double height=0) noexcept
 Draws a rectangle to the screen. More...
 
void draw_triangle (double x1, double y1, double x2, double y2, double x3, double y3) noexcept
 Draw a triangle to the screen. More...
 
void set_ellipse_mode (EllipseMode mode) noexcept
 Modifies the location from which ellipses are drawn by changing the way in which parameters given to draw_ellipse() are interpreted. More...
 
void set_rectangle_mode (RectMode mode) noexcept
 Modifies the location from which rectangles are drawn by changing the way in which parameters given to draw_rectangle() are interpreted. More...
 
void set_frame_of_reference (FrameOfReference frame_of_reference) noexcept
 Change the coordinate system you would like to use when describing your primitives. More...
 
void smooth_drawing () noexcept
 Draws all geometry with smooth (anti-aliased) edges. More...
 
void no_smoothing () noexcept
 Draws all geometry with jagged (aliased) edges. More...
 
void set_outline_width (double line_width) noexcept
 Sets the width of the outline used for lines and the border around shapes. All widths are set in units of pixels. More...
 
void push_settings () noexcept
 The push_settings() function saves the current drawing style settings and transformations, while pop_settings() restores these settings. More...
 
void pop_settings () noexcept
 The pop_settings() function restores to the previous style settings and transformations, while push_settings() saves a new set these settings. More...
 
void draw_text (const std::wstring &str, double x, double y) noexcept
 Draws wide character based text to the screen. More...
 
void draw_text (const std::string &str, double x, double y) noexcept
 Draws text to the screen. More...
 
int create_distance_field_bitmap_font (const std::filesystem::path &fnt_filepath) noexcept
 Given a file path to a *.fnt file it will create a distance field bitmap font. More...
 
void set_font (int font_id) noexcept
 Changes the font type to be used when drawing text. More...
 
void set_font_size (double font_size) noexcept
 Sets the current font size. This size will be used in all subsequent calls to the draw_text() function. More...
 
void set_font_fade_out_interval (double inside_distance, double outside_distance) noexcept
 Defines the distance interval to draw font characters and how to fade them out from opaque to translucent. More...
 
void set_font_backdrop_fade_out_interval (double inside_distance, double outside_distance) noexcept
 Defines the distance interval to draw the backdrop of font characters and how to fade them out from opaque to translucent. More...
 
void set_font_backdrop_offset (double texel_x, double texel_y) noexcept
 Repositions the backdrop of the font characters. Useful for creating a custom drop shadow effect. More...
 
Image capture_screenshot_to_image ()
 Captures a screenshot of the whole screen. More...
 
Image capture_screenshot_to_image (int left_x, int bottom_y, int pixels_width, int pixels_height) noexcept
 Captures a screenshot of a subsection of the screen. More...
 
void draw_image (const Image &image, double x, double y) noexcept
 Draw an entire image to the screen. More...
 
void draw_image (const Image &image, double x, double y, double width, double height) noexcept
 Draw an entire image to the screen and resize it to a custom size. More...
 
void draw_image (const Image &image, double x, double y, double width, double height, int texel_x, int texel_y) noexcept
 Draw a subsection of the image to the screen. More...
 
void draw_image (const Image &image, double x, double y, double width, double height, int texel_x, int texel_y, int texel_width, int texel_height) noexcept
 Draw a subsection of the image to the screen. More...
 
void set_tint_color (HexColor color) noexcept
 Sets the fill value for displaying images to the specified HexColor. More...
 
void set_tint_color (Color color) noexcept
 Sets the fill value for displaying textures to the specified Color. More...
 
void set_tint_color (double grey, double alpha=255) noexcept
 Sets the fill value for displaying textures to the specified grey color. More...
 
void set_tint_color (double red, double green, double blue, double alpha=255) noexcept
 Sets the fill value for displaying textures to the specified RGBA color. More...
 
void no_tint () noexcept
 Removes the current fill value for displaying images and reverts to displaying textures with their original colors. More...
 
void set_image_mode (RectMode mode) noexcept
 Modifies the location from which textures are drawn by changing the way in which parameters given to draw_image() are interpreted. More...
 
void apply_scale (double scale) noexcept
 Uniformly increases or decreases the size of a shape by expanding and contracting vertices. More...
 
void apply_scale (double scale_x, double scale_y) noexcept
 Increases or decreases the size of a shape by expanding and contracting vertices. More...
 
void apply_rotate (double angle_in_radians) noexcept
 Rotates a shape the amount specified by the angle in radians. More...
 
void apply_translate (double translate_x, double translate_y) noexcept
 Specifies an amount to displace objects within the display window. More...
 
void apply_matrix (double a, double b, double c, double d, double e, double f) noexcept
 Multiplies the current matrix by the one specified through the parameters. More...
 
void begin_drawing_to_image (int image_width, int image_height, bool apply_antialiasing=true)
 Redirect all draw command to draw to an image. More...
 
Image end_drawing_to_image (bool smooth_texture=false)
 End a session of drawing to an image. More...
 
std::string to_string (MouseButtons button) noexcept
 Convert MouseButtons enum to std::string. More...
 
std::string to_string (KeyboardButtons button) noexcept
 Convert KeboardButtons enum to std::string. More...
 
std::wstring to_wstring (MouseButtons button) noexcept
 Convert MouseButtons enum to std::wstring. More...
 
std::wstring to_wstring (KeyboardButtons button) noexcept
 Convert KeboardButtons enum to std::wstring. More...
 
int get_mouse_x () noexcept
 Get the mouse's X position relative to the currently set doodle::FrameOfReference. More...
 
int get_mouse_y () noexcept
 Get the mouse's Y position relative to the currently set doodle::FrameOfReference. More...
 
int get_previous_mouse_x () noexcept
 Get the previous mouse's X position relative to the currently set doodle::FrameOfReference. More...
 
int get_previous_mouse_y () noexcept
 Get the previous mouse's Y position relative to the currently set doodle::FrameOfReference. More...
 
void 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 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 set_callback_mouse_moved (std::function< void(int, int)> &&callback) noexcept
 The provided callback function is called every time the mouse moves. More...
 
void set_callback_mouse_pressed (std::function< void(MouseButtons)> &&callback) noexcept
 The provided callback is called whenever a mouse button is pressed. More...
 
void set_callback_mouse_released (std::function< void(MouseButtons)> &&callback) noexcept
 The provided callback is called whenever a mouse button is released. More...
 
void set_callback_mouse_wheel (std::function< void(int)> &&callback) noexcept
 The provided callback is called whenever the mouse wheel is scrolled. More...
 
double noise (double x, double y=0.0, double z=0.0) noexcept
 Returns the Perlin noise value at specified coordinates. More...
 
void seed_noise (unsigned long long new_seed) noexcept
 Sets the seed value for noise(). More...
 
void set_noise_detail (int perlin_octaves, double amplitude_falloff) noexcept
 Adjusts the character and level of detail produced by the Perlin noise function. More...
 
void seed_random (unsigned int seed) noexcept
 Sets the seed value for random(). More...
 
double random (double min_inclusive, double max_exclusive) noexcept
 Return a random floating-point number within the range [min,max) More...
 
double random (double max_exclusive) noexcept
 Return a random floating-point number within the range [0,max) More...
 
double random () noexcept
 Return a random floating-point number within the range [0,1) More...
 
int random (int min_inclusive, int max_exclusive) noexcept
 Return a random integer number within the range [min,max) More...
 
int random (int max_exclusive) noexcept
 Return a random integer number within the range [0,max) More...
 
bool create_window () noexcept
 Create a default window. More...
 
bool create_window (const std::string &title) noexcept
 Create a default window with a custom window title. More...
 
bool create_window (int desired_width, int desired_height) noexcept
 Create a window with a desired screen size. More...
 
bool create_window (const std::string &title, int desired_width, int desired_height) noexcept
 Create a window with a custom window title and a desired screen size. More...
 
bool create_window (const std::string &title, int desired_width, int desired_height, int screen_x, int screen_y) noexcept
 Create a window with a custom window title and a desired screen size. More...
 
bool is_window_closed () noexcept
 Is the window closed? More...
 
void update_window () noexcept
 Update the doodle application. More...
 
void close_window () noexcept
 Programmatically close the window. More...
 
void set_window_title (const std::string &new_title) noexcept
 Set a new title for the window. More...
 
bool is_full_screen () noexcept
 Is the window a fullscreen window? More...
 
void toggle_full_screen () noexcept
 Switch back and forth between fullscreen and windowed mode. More...
 
void set_callback_window_resized (std::function< void(int, int)> &&callback) noexcept
 The provided callback function is called whenever the window is resized by the user. More...
 
void set_callback_window_closed (std::function< void(void)> &&callback) noexcept
 The provided callback function will be called when the user uses the OS to close the window. More...
 
void set_callback_window_focus_changed (std::function< void(bool)> &&callback) noexcept
 THe provided callback function will be called when the window gains or loses focus. More...
 
void show_cursor (bool show_it=true) noexcept
 This function will allow you to hide or show the mouse cursor. More...
 

Variables

constexpr double PI = 3.1415926535897932384626433832795028
 \(\pi\) More...
 
constexpr double HALF_PI = PI / 2.0
 \(\frac{\pi}{2}\) More...
 
constexpr double QUARTER_PI = PI / 4.0
 \(\frac{\pi}{4}\) More...
 
constexpr double TWO_PI = 2.0 * PI
 \(2\pi\) More...
 
constexpr int DEFAULT_FONT_ID = 0
 Holds the ID value for the provided font that comes with doodle. More...
 
int FrameCount
 The system variable FrameCount contains the number of frames that have been displayed since the program started. The first call to update_window() will set the value to 1 and subsequent calls increment the value. More...
 
double DeltaTime
 The system variable DeltaTime contains the time difference between the beginning of the previous frame and the beginning of the current frame in seconds. More...
 
double ElapsedTime
 Returns the number of seconds since starting the program. This information is often used for timing events and animation sequences. More...
 
int Width
 System variable that stores the width of the drawing canvas. This value is set by the desired_width parameter of the create_window() function. For example, the function call create_window(320, 240) sets the width variable to the value 320. More...
 
int Height
 System variable that stores the height of the drawing canvas. This value is set by the desired_height parameter of the create_window() function. For example, the function call create_window(320, 240) sets the height variable to the value 240. More...
 
bool MouseIsPressed
 The boolean system variable MouseIsPressed is true if the mouse is pressed and false if not. More...
 
bool KeyIsPressed
 The boolean system variable KeyIsPressed is true if any key is pressed and false if no keys are pressed. More...
 
KeyboardButtons Key
 The system variable key always contains the value of the most recent key on the keyboard that was typed. More...
 
MouseButtons 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...
 
constexpr auto VERSION = "0.2.5"
 
bool WindowIsFocused
 Confirms if the window a doodle program is in is "focused," meaning that the doodle will accept mouse or keyboard input. This variable is "true" if the window is focused and "false" if not. More...
 

Enumeration Type Documentation

◆ KeyboardButtons

Enumerator
None 

Unhandled key.

_0 

The 0 key.

_1 

The 1 key.

_2 

The 2 key.

_3 

The 3 key.

_4 

The 4 key.

_5 

The 5 key.

_6 

The 6 key.

_7 

The 7 key.

_8 

The 8 key.

_9 

The 9 key.

The A key.

The B key.

The C key.

The D key.

The E key.

The F key.

The G key.

The H key.

The I key.

The J key.

The K key.

The L key.

The M key.

The N key.

The O key.

The P key.

The Q key.

The R key.

The S key.

The T key.

The U key.

The V key.

The W key.

The X key.

The Y key.

The Z key.

NumPad_0 

The numpad 0 key.

NumPad_1 

The numpad 1 key.

NumPad_2 

The numpad 2 key.

NumPad_3 

The numpad 3 key.

NumPad_4 

The numpad 4 key.

NumPad_5 

The numpad 5 key.

NumPad_6 

The numpad 6 key.

NumPad_7 

The numpad 7 key.

NumPad_8 

The numpad 8 key.

NumPad_9 

The numpad 9 key.

Escape 

The Escape key.

Control 

The Control key.

Shift 

The Shift key.

CapsLock 

The Caps Lock key.

LeftSystem 

The left OS specific key: window (Windows and Linux), apple (MacOS X), ...

RightSystem 

The right OS specific key: window (Windows and Linux), apple (MacOS X), ...

Menu 

The Menu key.

LeftBracket 

The [ key.

RightBracket 

The ] key.

Semicolon 

The ; key.

Comma 

The , key.

Period 

The . key.

Quote 

The ' key.

Slash 

The / key.

Backslash 

The \ key.

Tilde 

The ~ key.

Equal 

The = key.

Hyphen 

The - key (hyphen)

Space 

The Space key.

Enter 

The Enter/Return keys.

Backspace 

The Backspace key.

Tab 

The Tabulation key.

PageUp 

The Page up key.

PageDown 

The Page down key.

End 

The End key.

Home 

The Home key.

PrintScreen 

The Print Screen key.

Insert 

The Insert key.

Delete 

The Delete key.

Add 

The + key.

Subtract 

The - key (minus, usually from numpad)

Multiply 

The * key.

Divide 

The / key.

Left 

Left arrow.

Right 

Right arrow.

Up 

Up arrow.

Down 

Down arrow.

F1 

The F1 key.

F2 

The F2 key.

F3 

The F3 key.

F4 

The F4 key.

F5 

The F5 key.

F6 

The F6 key.

F7 

The F7 key.

F8 

The F8 key.

F9 

The F9 key.

Pause 

The Pause key.

Count 

the total number of keyboard keys

Definition at line 25 of file input.hpp.

26  {
27  None,
28  _0,
29  _1,
30  _2,
31  _3,
32  _4,
33  _5,
34  _6,
35  _7,
36  _8,
37  _9,
38  A,
39  B,
40  C,
41  D,
42  E,
43  F,
44  G,
45  H,
46  I,
47  J,
48  K,
49  L,
50  M,
51  N,
52  O,
53  P,
54  Q,
55  R,
56  S,
57  T,
58  U,
59  V,
60  W,
61  X,
62  Y,
63  Z,
64  NumPad_0,
65  NumPad_1,
66  NumPad_2,
67  NumPad_3,
68  NumPad_4,
69  NumPad_5,
70  NumPad_6,
71  NumPad_7,
72  NumPad_8,
73  NumPad_9,
74  Escape,
75  Control,
76  Shift,
77  CapsLock,
78  LeftSystem,
79  RightSystem,
80  Menu,
81  LeftBracket,
82  RightBracket,
83  Semicolon,
84  Comma,
85  Period,
86  Quote,
87  Slash,
88  Backslash,
89  Tilde,
90  Equal,
91  Hyphen,
92  Space,
93  Enter,
94  Backspace,
95  Tab,
96  PageUp,
97  PageDown,
98  End,
99  Home,
100  PrintScreen,
101  Insert,
102  Delete,
103  Add,
104  Subtract,
105  Multiply,
106  Divide,
107  Left,
108  Right,
109  Up,
110  Down,
111  F1,
112  F2,
113  F3,
114  F4,
115  F5,
116  F6,
117  F7,
118  F8,
119  F9,
120  Pause,
121  Count
122  };
@ None
Unhandled Button.
@ Right
Right Mouse Button.
@ Left
Left Mouse Button.
@ Count
the total number of mouse button keys
@ Escape
The Escape key.
@ Pause
The Pause key.
@ NumPad_0
The numpad 0 key.
@ Subtract
The - key (minus, usually from numpad)
@ NumPad_1
The numpad 1 key.
@ NumPad_8
The numpad 8 key.
@ NumPad_9
The numpad 9 key.
@ Tab
The Tabulation key.
@ NumPad_4
The numpad 4 key.
@ Hyphen
The - key (hyphen)
@ Shift
The Shift key.
@ LeftSystem
The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
@ CapsLock
The Caps Lock key.
@ PageUp
The Page up key.
@ NumPad_7
The numpad 7 key.
@ Control
The Control key.
@ Insert
The Insert key.
@ PrintScreen
The Print Screen key.
@ NumPad_3
The numpad 3 key.
@ NumPad_2
The numpad 2 key.
@ Backspace
The Backspace key.
@ Space
The Space key.
@ RightSystem
The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
@ NumPad_5
The numpad 5 key.
@ PageDown
The Page down key.
@ Enter
The Enter/Return keys.
@ Delete
The Delete key.
@ NumPad_6
The numpad 6 key.

◆ MouseButtons

enum doodle::MouseButtons
strong
Enumerator
None 

Unhandled Button.

Left 

Left Mouse Button.

Middle 

Middle Mouse Button.

Right 

Right Mouse Button.

Count 

the total number of mouse button keys

Definition at line 16 of file input.hpp.

17  {
18  None,
19  Left,
20  Middle,
21  Right,
22  Count
23  };
@ Middle
Middle Mouse Button.

Variable Documentation

◆ VERSION

constexpr auto doodle::VERSION = "0.2.5"
constexpr

Definition at line 12 of file version.hpp.