Class Bresenham2i

Nested Relationships

Nested Types

Class Documentation

class Bresenham2i

Bresenham’s 2D line drawing algorithm, optimized for integer arithmetic.

Public Types

enum Variant

Bresenham’s 2D line drawing algorithm variants.

Values:

enumerator kStandard

Standard Bresenham’s algorithm.

enumerator kModified

Modified, aka supercover, Bresenham’s algorithm. See http://eugen.dedu.free.fr/projects/bresenham.

Public Functions

Bresenham2i() noexcept = default

Constructs standard Bresenham 2D line drawing algorithm.

Bresenham2i(const Bresenham2i&) noexcept = default

Default copy constructor.

Bresenham2i(Bresenham2i&&) noexcept = default

Default move constructor.

Bresenham2i &operator=(const Bresenham2i&) noexcept = default

Default copy assignment operator overload.

Bresenham2i &operator=(Bresenham2i&&) noexcept = default

Default move assignment operator overload.

inline explicit Bresenham2i(Variant variant) noexcept

Constructs specific Bresenham 2D line drawing algorithm variant.

template<class Vector2i = Eigen::Vector2i>
inline auto operator()(Vector2i p0, Vector2i p1) const

Computes 2D line from p0 to p1.

Template Parameters:

Vector2i – Point in 2D integer space ie. ℤ × ℤ.

Parameters:
  • p0 – Start point in 2D integer space.

  • p1 – End point in 2D integer space.

Returns:

subtended bresenham2i::line.

template<class Vector2, typename Integer = typename Vector2::Scalar>
class Line : public ranges::view_interface<Line<Vector2, typename Vector2::Scalar>>

Bresenham’s 2D line drawing as a range.

Template Parameters:
  • Vector2 – 2D vector type. Must be default constructible, copy constructible, and implement Vector2d::x() and Vector2::y() methods returning both lvalues (for mutation) and rvalues.

  • Integer – Integer scalar type.

Public Functions

Line() = default

Constructs point line.

inline explicit Line(Vector2 p0, Vector2 p1, Variant variant)

Constructs a Bresenham’s 2D line drawing.

Parameters:
  • p0Line start point in 2D space.

  • p1Line end point in 2D space.

  • variant – Bresenham’s algorithm variant to be used.

inline auto begin() const

Returns an iterator pointing to the first point in the line.

inline auto end() const

Returns a sentinel as past-of-end iterator.

class iterator

Bresenham’s 2D line drawing iterator, one cell at a time.

Public Types

using iterator_category = std::forward_iterator_tag

Iterator category tag.

using difference_type = std::ptrdiff_t

Iterator difference type (as required by ranges::view_).

using value_type = Vector2

Iterated value type.

using pointer = Vector2*

Pointer to iterated value type.

using reference = Vector2&

Reference to iterated value type.

Public Functions

iterator() = default

Default constructor.

inline explicit iterator(const Line *line)

Constructs a Bresenham’s 2D line iterator.

inline iterator operator++(int)

Post-fix operator overload.

inline iterator &operator++()

Prefix operator overload.

inline const Vector2 &operator*() const

Dereference operator overload (only const).

inline const Vector2 *operator->() const

Arrow operator overload (only const).

inline bool operator==(const iterator &other) const

Equality operator overload (as required by std::forward_iterator).

inline bool operator!=(const iterator &other) const

Inequality operator overload (as required by std::forward_iterator).

inline bool operator==(const sentinel&) const

Sentinel equality operator overload.

inline bool operator!=(const sentinel &other) const

Sentinel inequality operator overload.

struct sentinel

Past-of-end iterator sentinel.

Public Functions

inline bool operator==(const iterator &other) const

Equality operator overload, for symmetry (as required by ranges::sentinel_for).

inline bool operator!=(const iterator &other) const

Inequality operator overload, for symmetry (as required by ranges::sentinel_for).