diff --git a/docs/pseudo-containers/_index.md b/docs/pseudo-containers/_index.md index e88f4c4a..6f72ae49 100644 --- a/docs/pseudo-containers/_index.md +++ b/docs/pseudo-containers/_index.md @@ -3,3 +3,4 @@ title: "Pseudo containers" weight: 100 --- +Data and data generators tha have a container-like interface. diff --git a/docs/raw/pseudo-containers/bresenham_line.txt b/docs/raw/pseudo-containers/bresenham_line.txt deleted file mode 100644 index ed3c1fcb..00000000 --- a/docs/raw/pseudo-containers/bresenham_line.txt +++ /dev/null @@ -1,88 +0,0 @@ -bresenham_line - -A 'pseudo' container that generates coordinates on a line between two points using the Bresenham line algorithm. -The class has an STL-like API and is a forward iterator type container. - -Note: The iterator only supports pre-increment. - -etl::bresenham_line -Where T is the coordinate element type. -___________________________________________________________________________________________________ -Member types - -value_type etl::coordinate_2d -size_type std::size_t -difference_type std::ptrdiff_t -const_reference const value_type& -const_pointer const value_type* -const_iterator Constant forward iterator -____________________________________________________________________________________________________ -Constructor - -etl::bresenham_line(); -etl::bresenham_line(T first_x, T first_y, T last_x, T last_y); -etl::bresenham_line(const etl::coordinate_2d& first, const etl::coordinate_2d& last); -____________________________________________________________________________________________________ -Initialisation - -void reset(T first_x, T first_y, T last_x, T last_y); -void reset(const etl::coordinate_2d& first, const etl::coordinate_2d& last); -____________________________________________________________________________________________________ -Element access - -const_reference front() const -Returns a const reference to the first coordinate in the line. -____________________________________________________________________________________________________ -const_reference back() const -Returns a const reference to the last coordinate in the line. -____________________________________________________________________________________________________ -Iterators - -const_iterator begin() -Returns an iterator to the beginning of the coordinate series. -This will reset the Bresenham line algorithm to the first coordinate. -____________________________________________________________________________________________________ -const_iterator end() const -Returns an iterator to the end of the coordinate series. -____________________________________________________________________________________________________ -Capacity - -size_t size() const -Returns the number of coordinates in the series. -____________________________________________________________________________________________________ -Non-member functions - -== true if the two lines are equal, otherwise false. -!= true if the two lines are not equal, otherwise false. -____________________________________________________________________________________________________ -Examples - -Plot pixels on a line -std::ostream& operator << (std::ostream& os, const etl::coordinate_2d& coordinate) -{ - os << "(" << coordinate.x << "," << coordinate.y << ")"; - return os; -} - -etl::coordinate_2d first = { -3, 5 }; -etl::coordinate_2d last = { 3, -5 }; - -etl::bresenham_line line(first, last); - -std::cout << "There are " << line.size() << " coordinates between " << line.front() << " and " << line.back(); - -// Plot the pixels between first and last. -std::for_each(line.begin(), line.end(), PlotPixel); - - -Create a vector of pixels on a line -etl::coordinate_2d first = { -3, 5 }; -etl::coordinate_2d last = { 3, -5 }; - -etl::bresenham_line line(first, last); - -std::vector> coordinates; - -// Create the vector of points on the line between first and last. -std::copy(line.begin(), line.end(), std::back_inserter(coordinates)); -