From 58c96b9027e1f7dd3743936a7adb85f1ba19c475 Mon Sep 17 00:00:00 2001 From: Pascal Engeler <engelerp@phys.ethz.ch> Date: Mon, 30 Aug 2021 17:00:12 +0200 Subject: [PATCH] drawer documented --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 147223b..995791d 100644 --- a/README.md +++ b/README.md @@ -121,49 +121,91 @@ Todo 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)` - - DESCRIPTION + - **Description** Draw a stroke from the last position to (x, y), with strokewidth controlled by `drawing` (`true`->`tb.drawing_width`, `false`->`tb.erasing_width`). - - PRECONDITIONS + - **Preconditions** A `GL_ARRAY_BUFFER` is bound and the Opengl state is set as desired - - POSTCONDITIONS + - **Postconditions** - The points of the new segment have been calculated, a call to `glDrawArrays` has been done to draw the segment. + The points of the new segment have been calculated and uploaded to the currently bound `GL_ARRAY_BUFFER`, a call to `glDrawArrays` has been done to draw the segment. Returns `true` if something was drawn, and `false` else (typically when new point is same as last point). - - NOTES + - **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. + - **Description**: + + Redraws the last drawn stroke. + + - **Preconditions**: + + `draw` has been called at least once, and since the last call to `draw`, the then-bound `GL_ARRAY_BUFFER` has not been modified. + + - **Postconditions**: + + A drawcall `glDrawArrays` has been issued. + + - **Notes**: - `void erase(const float x, const float y, Toolbox& tb)` **DEPRECATED** - - *Desc*: - - *Pre*: - - *Post*: - - *Notes*: Use `draw(x, y, tb, false)` instead. + - **Description**: + + + + - **Preconditions**: + + + + - **Postconditions**: + + + + - **Notes**: + + Use `draw(x, y, tb, false)` instead. - `int num_drawn()` - - *Desc*: Returns the number of calls to `draw` and `erase` that have been performed by this object. - - *Pre*: - - *Post*: - - *Notes*: + - **Description**: + + Returns the number of calls to `draw` and `erase` that have been performed by this object. + + - **Preconditions**: + + + + - **Postconditions**: + + + + - **Notes**: + + **Private Function Members** - `bool calculate_points_(Toolbox& tb, bool drawing)` + - **Description**: + + Calculate the triangulation of the stroke represented by the internal parameters, and store them in `points_`. + The stroke width is controlled by `drawing` (`true`->`tb.drawing_width`, `false`->`tb.erasing_width`). + + - **Preconditions**: + + The points (`x0_`, `y0_`) and (`x1_`, `y1_`) are set as desired. + + - **Postconditions**: + + If the points (`x0_`, `y0_`), (`x1_`, `y1_`) are the same, false has been returned and the call has no effect. + Else, `true` has been returned, and the vertices that make up the segment between these two points with the desired width have been calculated and stored in `points_`. - Calculates the triangulation of the stroke represented by the internal parameters and stores them in `points_`. - The `drawing` argument switches the stroke width (`true`->`tb.drawing_width`, `false`->`tb.erasing_width`). - Uses `tb.texture_w`. - Returns `true` if new points were calculated, and `false` else (typically if the internal state represents an equal new and old point). - + - **Notes**: + + **Public Data Members** -- GitLab