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 | |
void | doodle::apply_scale (double scale) noexcept |
Uniformly increases or decreases the size of a shape by expanding and contracting vertices. More... | |
void | doodle::apply_scale (double scale_x, double scale_y) noexcept |
Increases or decreases the size of a shape by expanding and contracting vertices. More... | |
void | doodle::apply_rotate (double angle_in_radians) noexcept |
Rotates a shape the amount specified by the angle in radians. More... | |
void | doodle::apply_translate (double translate_x, double translate_y) noexcept |
Specifies an amount to displace objects within the display window. More... | |
void | doodle::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... | |
|
noexcept |
Multiplies the current matrix by the one specified through the parameters.
This is a powerful operation that can perform the equivalent of translate, scale, shear and rotate all at once. You can learn more about transformation matrices on Wikipedia.
The naming of the arguments here follows the naming of the WHATWG specification and corresponds to a transformation matrix of the form:
\( \begin{bmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{bmatrix} \)
a | 1st Column 1 Row |
b | 1st Column 2nd Row |
c | 2nd Column 1st Row |
d | 2nd Column 2nd Row |
e | 3rd Column 1st Row |
f | 3rd Column 2nd Row |
|
noexcept |
Rotates a shape the amount specified by the angle in radians.
Objects are always rotated around their relative position to the origin. If the doodle::FrameOfReference is right-handed then positive angles rotate counter-clockwise and if it is left-handed then positive angles rotate clockwise. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling apply_rotate(HALF_PI) and then apply_rotate(HALF_PI) is the same as apply_rotate(PI). All transformations are reset when update_window() is called.
Technically, apply_rotate() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the push_settings() and pop_settings().
angle_in_radians | the angle of rotation |
|
noexcept |
Uniformly increases or decreases the size of a shape by expanding and contracting vertices.
Objects always scale from their relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the function call apply_scale(2.0) increases the dimension of a shape by 200%.
Transformations apply to everything that happens after and subsequent calls to the function multiply the effect. For example, calling apply_scale(2.0) and then apply_scale(1.5) is the same as apply_scale(3.0). The transformation is reset when update_window() is called.
scale | percent to scale the object |
|
noexcept |
Increases or decreases the size of a shape by expanding and contracting vertices.
Objects always scale from their relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the function call apply_scale(2.0, 0.5) increases the dimension of a shape horizontally by 200% and vertically bu 50%.
Transformations apply to everything that happens after and subsequent calls to the function multiply the effect. For example, calling apply_scale(2.0, 1.0) and then apply_scale(1.5, 2.0) is the same as apply_scale(3.0, 2.0). The transformation is reset when update_window() is called.
scale_x | percentage to scale the object in the x-axis |
scale_y | percentage to scale the object in the y-axis |
|
noexcept |
Specifies an amount to displace objects within the display window.
The x parameter specifies left/right translation, the y parameter specifies up/down translation.
Transformations are cumulative and apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling apply_translate(50, 0) and then apply_translate(20, 0) is the same as apply_translate(70, 0). All transformations are reset when update_window() is called. This function can be further controlled by the push_settings() and pop_settings().
translate_x | left/right translation |
translate_y | up/down translation |