|
roo_display
API Documentation for roo_display
|
Primary top-level interface for drawing to screens, off-screen buffers, or other devices. More...
#include <roo_display.h>
Public Member Functions | |
| template<typename Display > | |
| DrawingContext (Display &display) | |
| Constructs a drawing context covering the entire display. | |
| template<typename Display > | |
| DrawingContext (Display &display, Box bounds) | |
| Constructs a drawing context covering the specified bounds, relative to the display's extents. If bounds exceed the display's extents, they will be clipped accordingly, but the requested bounds will still be used for alignment purposes. For example, drawing a centered object will center it relative to the bounds(), even if they exceed the display's extents. | |
| template<typename Display > | |
| DrawingContext (Display &display, int16_t x_offset, int16_t y_offset) | |
| Constructs a drawing context covering the entire display, with device coordinates offset by the specified amounts. | |
| template<typename Display > | |
| DrawingContext (Display &display, int16_t x_offset, int16_t y_offset, Box bounds) | |
| Constructs a drawing context covering the specified bounds, with device coordinates offset by the specified amounts. The bounds are expressed post-translation. That is, bounds corresponding to the entire display surface would be equal to display.extents().translate(-x_offset, -y_offset). If bounds exceed the display's extents, they will be clipped accordingly, but the requested bounds will still be used for alignment purposes. For example, drawing a centered object will center it relative to the requested bounds, even if they exceed the display's extents. | |
| ~DrawingContext () | |
| const Box & | bounds () const |
| Returns the bounds used for alignment. | |
| const uint16_t | width () const |
| Returns the width of the drawing context. Equivalent to bounds().width(). | |
| const uint16_t | height () const |
| Returns the height of the drawing context. Equivalent to bounds().height(). | |
| void | setBackground (const Rasterizable *bg) |
| const Rasterizable * | getBackground () const |
| Color | getBackgroundColor () const |
| void | setBackgroundColor (Color bgcolor) |
| FillMode | fillMode () const |
| void | setFillMode (FillMode fill_mode) |
| BlendingMode | blendingMode () const |
| void | setBlendingMode (BlendingMode blending_mode) |
| void | clear () |
| Clears the display, respecting the clip box, and background settings. | |
| void | fill (Color color) |
| Fills the display with the specified color, respecting the clip box. | |
| void | setClipBox (const Box &clip_box) |
| Sets the clip box, intersected with the maximum allowed clip box. Expressed in device coordinates. | |
| void | setClipBox (int16_t x0, int16_t y0, int16_t x1, int16_t y1) |
| Sets the clip box, intersected with the maximum allowed clip box. Expressed in device coordinates. | |
| void | setClipMask (const ClipMask *clip_mask) |
| const Box & | getClipBox () const |
| Returns the current clip box, in device coordinates. | |
| void | setTransformation (Transformation t) |
| Sets a transformation to be applied to all drawn objects when converting the drawing coordinates to device coordinates. | |
| const Transformation & | transformation () const |
| Returns the current transformation. (The identity transformation by default). | |
| void | setWriteOnce () |
| bool | isWriteOnce () const |
| void | drawPixels (const std::function< void(ClippingBufferedPixelWriter &)> &fn, BlendingMode blending_mode=BlendingMode::kSourceOver) |
Allows to efficiently draw pixels to the context, using a buffered pixel writer (avoiding virtual calls per pixel, and allowing for batch writes). The provided function fn will be called with a ClippingBufferedPixelWriter that respects the current clip box and uses the specified blending mode. | |
| void | draw (const Drawable &object) |
| Draws the object using its inherent coordinates. The point (0, 0) in the object's coordinates maps to (0, 0) in the context's coordinates (subject to the optional transformation). | |
| void | draw (const Drawable &object, int16_t dx, int16_t dy) |
| Draws the object using the specified absolute offset. The point (0, 0) in the object's coordinates maps to (dx, dy) in the context's coordinates (subject to the optional transformation). | |
| void | draw (const Drawable &object, Alignment alignment) |
| Draws the object applying the specified alignment, relative to the bounds(). For example, for with kMiddle | kCenter, the object will be centered relative to the bounds(). | |
| void | erase (const Drawable &object) |
| Analogous to draw(object), but instead of drawing, replaces all the output pixels with the background color. | |
| void | erase (const Drawable &object, int16_t dx, int16_t dy) |
| Analogous to draw(object, dx, dy), but instead of drawing, replaces all the output pixels with the background color. | |
| void | erase (const Drawable &object, Alignment alignment) |
| Analogous to draw(object, alignment), but instead of drawing, replaces all the output pixels with the background color. | |
Primary top-level interface for drawing to screens, off-screen buffers, or other devices.
Supports rectangular clip regions, as well as arbitrary clip masks.
Able to render objects implementing the Drawable interface.
Definition at line 225 of file roo_display.h.
Constructs a drawing context covering the entire display.
Definition at line 229 of file roo_display.h.
Constructs a drawing context covering the specified bounds, relative to the display's extents. If bounds exceed the display's extents, they will be clipped accordingly, but the requested bounds will still be used for alignment purposes. For example, drawing a centered object will center it relative to the bounds(), even if they exceed the display's extents.
Definition at line 238 of file roo_display.h.
|
inline |
Constructs a drawing context covering the entire display, with device coordinates offset by the specified amounts.
Definition at line 244 of file roo_display.h.
|
inline |
Constructs a drawing context covering the specified bounds, with device coordinates offset by the specified amounts. The bounds are expressed post-translation. That is, bounds corresponding to the entire display surface would be equal to display.extents().translate(-x_offset, -y_offset). If bounds exceed the display's extents, they will be clipped accordingly, but the requested bounds will still be used for alignment purposes. For example, drawing a centered object will center it relative to the requested bounds, even if they exceed the display's extents.
Definition at line 257 of file roo_display.h.
| roo_display::DrawingContext::~DrawingContext | ( | ) |
Definition at line 160 of file roo_display.cpp.
|
inline |
Definition at line 299 of file roo_display.h.
Returns the bounds used for alignment.
Definition at line 281 of file roo_display.h.
Referenced by draw().
| void roo_display::DrawingContext::clear | ( | ) |
Clears the display, respecting the clip box, and background settings.
Definition at line 105 of file roo_display.cpp.
Referenced by roo_display::Display::clear().
Draws the object using its inherent coordinates. The point (0, 0) in the object's coordinates maps to (0, 0) in the context's coordinates (subject to the optional transformation).
Definition at line 357 of file roo_display.h.
Draws the object applying the specified alignment, relative to the bounds(). For example, for with kMiddle | kCenter, the object will be centered relative to the bounds().
Definition at line 371 of file roo_display.h.
References bounds(), roo_display::Offset::dx, roo_display::Offset::dy, roo_display::Alignment::resolveOffset(), and roo_display::Transformation::transformBox().
Draws the object using the specified absolute offset. The point (0, 0) in the object's coordinates maps to (dx, dy) in the context's coordinates (subject to the optional transformation).
Definition at line 364 of file roo_display.h.
| void roo_display::DrawingContext::drawPixels | ( | const std::function< void(ClippingBufferedPixelWriter &)> & | fn, |
| BlendingMode | blending_mode = BlendingMode::kSourceOver |
||
| ) |
Allows to efficiently draw pixels to the context, using a buffered pixel writer (avoiding virtual calls per pixel, and allowing for batch writes). The provided function fn will be called with a ClippingBufferedPixelWriter that respects the current clip box and uses the specified blending mode.
Definition at line 169 of file roo_display.cpp.
References blending_mode.
Analogous to draw(object), but instead of drawing, replaces all the output pixels with the background color.
Definition at line 247 of file roo_display.cpp.
Analogous to draw(object, alignment), but instead of drawing, replaces all the output pixels with the background color.
Definition at line 255 of file roo_display.cpp.
Analogous to draw(object, dx, dy), but instead of drawing, replaces all the output pixels with the background color.
Definition at line 251 of file roo_display.cpp.
Fills the display with the specified color, respecting the clip box.
Definition at line 95 of file roo_display.cpp.
References color.
|
inline |
Definition at line 296 of file roo_display.h.
|
inline |
Definition at line 291 of file roo_display.h.
|
inline |
Definition at line 293 of file roo_display.h.
Returns the current clip box, in device coordinates.
Definition at line 325 of file roo_display.h.
Returns the height of the drawing context. Equivalent to bounds().height().
Definition at line 288 of file roo_display.h.
References roo_display::Box::height().
|
inline |
Definition at line 344 of file roo_display.h.
|
inline |
Definition at line 290 of file roo_display.h.
Definition at line 294 of file roo_display.h.
References bgcolor.
|
inline |
Definition at line 300 of file roo_display.h.
References blending_mode.
Sets the clip box, intersected with the maximum allowed clip box. Expressed in device coordinates.
Definition at line 312 of file roo_display.h.
References roo_display::Box::Intersect().
Referenced by setClipBox().
|
inline |
Sets the clip box, intersected with the maximum allowed clip box. Expressed in device coordinates.
Definition at line 318 of file roo_display.h.
References setClipBox().
Definition at line 322 of file roo_display.h.
Definition at line 297 of file roo_display.h.
References fill_mode.
|
inline |
Sets a transformation to be applied to all drawn objects when converting the drawing coordinates to device coordinates.
Definition at line 333 of file roo_display.h.
References roo_display::Transformation::is_rescaled(), roo_display::Transformation::is_translated(), and roo_display::Transformation::xy_swap().
| void roo_display::DrawingContext::setWriteOnce | ( | ) |
Definition at line 162 of file roo_display.cpp.
|
inline |
Returns the current transformation. (The identity transformation by default).
Definition at line 340 of file roo_display.h.
Returns the width of the drawing context. Equivalent to bounds().width().
Definition at line 284 of file roo_display.h.
References roo_display::Box::width().