Numworks Epsilon  1.4.1
Graphing Calculator Operating System
context.h
Go to the documentation of this file.
1 #ifndef KANDINSKY_CONTEXT_H
2 #define KANDINSKY_CONTEXT_H
3 
4 #include <kandinsky/color.h>
5 #include <kandinsky/rect.h>
6 #include <kandinsky/text.h>
7 
8 class KDContext {
9 public:
10  void setOrigin(KDPoint origin);
11  void setClippingRect(KDRect clippingRect);
12 
13  // Pixel manipulation
14  void setPixel(KDPoint p, KDColor c);
16 
17  // Text
18  KDPoint drawString(const char * text, KDPoint p, KDText::FontSize size = KDText::FontSize::Large, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1);
19  KDPoint blendString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor = KDColorBlack);
20 
21  // Line. Not anti-aliased.
22  void drawLine(KDPoint p1, KDPoint p2, KDColor c);
23 
24  // Rect
25  void fillRect(KDRect rect, KDColor color);
26  void fillRectWithPixels(KDRect rect, const KDColor * pixels, KDColor * workingBuffer);
27  void blendRectWithMask(KDRect rect, KDColor color, const uint8_t * mask, KDColor * workingBuffer);
28  void strokeRect(KDRect rect, KDColor color);
29 protected:
30  KDContext(KDPoint origin, KDRect clippingRect);
31  virtual void pushRect(KDRect, const KDColor * pixels) = 0;
32  virtual void pushRectUniform(KDRect rect, KDColor color) = 0;
33  virtual void pullRect(KDRect rect, KDColor * pixels) = 0;
34 private:
35  KDRect absoluteFillRect(KDRect rect);
36  KDPoint writeString(const char * text, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, int maxLength, bool transparentBackground);
37  void writeChar(char character, KDPoint p, KDText::FontSize size, KDColor textColor, KDColor backgroundColor, bool transparentBackground);
38  KDPoint m_origin;
39  KDRect m_clippingRect;
40 };
41 
42 #endif
void strokeRect(KDRect rect, KDColor color)
void setPixel(KDPoint p, KDColor c)
KDContext(KDPoint origin, KDRect clippingRect)
Definition: context.cpp:4
KDPoint drawString(const char *text, KDPoint p, KDText::FontSize size=KDText::FontSize::Large, KDColor textColor=KDColorBlack, KDColor backgroundColor=KDColorWhite, int maxLength=-1)
Definition: context_text.cpp:9
void blendRectWithMask(KDRect rect, KDColor color, const uint8_t *mask, KDColor *workingBuffer)
unsigned char uint8_t
Definition: stdint.h:4
void setOrigin(KDPoint origin)
Definition: context.cpp:10
KDPoint blendString(const char *text, KDPoint p, KDText::FontSize size, KDColor textColor=KDColorBlack)
Definition: point.h:6
c(generic_all_nodes)
void drawLine(KDPoint p1, KDPoint p2, KDColor c)
Definition: context_line.cpp:4
virtual void pullRect(KDRect rect, KDColor *pixels)=0
constexpr KDColor KDColorWhite
Definition: color.h:42
virtual void pushRect(KDRect, const KDColor *pixels)=0
virtual void pushRectUniform(KDRect rect, KDColor color)=0
void setClippingRect(KDRect clippingRect)
Definition: context.cpp:14
constexpr KDColor KDColorBlack
Definition: color.h:41
void fillRectWithPixels(KDRect rect, const KDColor *pixels, KDColor *workingBuffer)
Definition: rect.h:26
void fillRect(KDRect rect, KDColor color)
Definition: context_rect.cpp:8
Definition: color.h:6
FontSize
Definition: text.h:10
KDColor getPixel(KDPoint p)