diff --git a/README.md b/README.md index 295a24a56e166fdc13e10c14d97b8f84363bda47..ead19f504c108d895941e779b0b4f11c1b183700 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,11 @@ Todo ### Drawer ([drawer.hpp](include/drawer.hpp), [drawer.cpp](src/drawer.cpp)) **Description** - A `Drawer` is an object that can draw segments to the screen. + A `Drawer` is an object that can draw a single line of segments to the screen. It handles single touch of the `Zeichnen` functionality. Note that this class relies on the caller to its methods to take care of the Opengl state (using shaders, binding buffers, etc.). See `DrawingHandler` for more information on how this class is to be used. + The coordinates used are typically OpenGL coordinates, i.e. in the range [-1, 1]. **Usage** - Construct object (e.g. when new finger goes down) @@ -105,33 +106,37 @@ Todo **Public Function Members** - `void start_drawing(const float x, const float y)`: - - Signal that this object's drawing starts at coordinates (`x`, `y`) (typically the fingerdown location). - The two arguments are both in [-1, 1]. - Nothing is drawn by this function. + - *Desc*: Start drawing at coordinates (`x`, `y`) (typically fingerdown location). Doesn't draw anything. + - *Pre*: + - *Post*: Drawing start is set to (x, y). + - *Notes*: Nothing is drawn by this function. (x, y) are typically the fingerdown coordinates. - `bool draw(const float x, const float y, Toolbox& tb, bool drawing)` - - Draws a stroke from the last position to (`x`, `y`). - The `tb` and `drawing` arguments are passed on to `calculate_points`. - - First updates the position and calculates the new points, uploads them to the current `GL_ARRAY_BUFFER` and finally draws them via `glDrawArrays`. + - *Desc*: Draw a stroke from the last position to (x, y), with strokewidth controlled by `drawing` (`true`->`tb.drawing_width`, `false`->`tb.erasing_width`). + - *Pre*: A `GL_ARRAY_BUFFER` is bound and the Opengl state is set as desired + - *Post*: The points of the new segment have been calculated, a call to `glDrawArrays` has been done to draw the segment. - Returns `true` if something was drawn, and `false` else (typically if the new point is equal to the previous point). + Returns `true` if something was drawn, and `false` else (typically when new point is same as last point). + - *Notes*: - `void redraw(Toolbox&)` + - *Desc*: Redraws the last drawn stroke. + - *Pre*: Since the last call to `draw`, the then-bound `GL_ARRAY_BUFFER` has not been modified. + - *Post*: A drawcall `glDrawArrays` has been issued. + - *Notes*: Undefined behaviour if `draw` has never been called, or the precondition is violated. Issues a drawcall (`glDrawArrays`). The argument is unused. Correct usage first calls `draw`, then calls `redraw` without changing the state of `GL_ARRAY_BUFFER` in between (typically, framebuffer and texture bindings are changed in between). -- `void erase(const float x, const float y, Toolbox& tb)` - - Deprecated, use `draw(x, y, tb, false)` instead. +- `void erase(const float x, const float y, Toolbox& tb)` **DEPRECATED** + - *Notes*: Use `draw(x, y, tb, false)` instead. - `int num_drawn()` - - Returns the number of calls to `draw` and `erase` performed by this object. + - *Desc*: Returns the number of calls to `draw` and `erase` that have been performed by this object. + - *Pre*: + - *Post*: + - *Notes*: **Private Function Members** - `bool calculate_points_(Toolbox& tb, bool drawing)`