16#define IS_MODE(mode, flag) (((mode) & (flag)) != 0)
18#define SWAP(type, src, dst) \
27#define SET_POINT(mode, color, x, y) \
29 if (IS_MODE(mode, MD_DRAW_BBOX)) \
30 LCD_SetPointColor(color, (LCD_Coordinate){x, y}); \
31 else if (IS_MODE(mode, MD_DELETE)) \
32 LCD_SetPointColor(LCDCurrentBGColor, (LCD_Coordinate){x, y}); \
52 int dx = abs(to.x - from.
x);
53 int dy = abs(to.y - from.
y);
56 int x_step = (from.
x < to.x) ? 1 : -1;
57 int y_step = (from.
y < to.y) ? 1 : -1;
62 while (from.
y != to.y + y_step)
70 while (from.
x != to.x + x_step)
78 int tmp = 2 * dy - dx;
79 while (from.
x != to.x + x_step)
86 tmp += 2 * dy - 2 * dx;
94 int tmp = 2 * dx - dy;
95 while (from.
y != to.y + y_step)
102 tmp += 2 * dx - 2 * dy;
112 if (original_from.
x > original_to.x)
113 SWAP(
u16, original_from.
x, original_to.x)
115 if (original_from.
y > original_to.y)
116 SWAP(
u16, original_from.
y, original_to.y)
173 for (
u16 i = from.
x + 1; i < to.
x; i++)
174 for (
u16 j = from.
y + 1; j < to.
y; j++)
190 if (!circle || !mode || circle->
radius == 0)
206 u16 x = radius, y = 0;
224 p += (2 * (y - x) + 1);
243 i16 x_diff, y_diff, rad_sq;
244 for (
u16 i = center.
x - radius + 1; i < center.
x + radius; i++)
246 for (
u16 j = center.
y - radius + 1; j < center.
y + radius; j++)
248 x_diff = (i - center.
x) * (i - center.
x);
249 y_diff = (j - center.
y) * (j - center.
y);
250 rad_sq = radius * radius;
251 if (x_diff + y_diff <= rad_sq)
269 if (!img || !img->
pixels || !mode)
273 if (width == 0 || height == 0)
291 u16 current_x, pixels_left, count;
292 for (
u16 i = 0; i < height; i++)
297 while (pixels_left > 0)
299 count = *pixels_copy++;
300 pixel_data = *pixels_copy++;
303 for (
u16 j = 0; j < count && pixels_left > 0; j++)
308 alpha_data = (
u8)(pixel_data >> 24);
309 rgb888 = (
u32)(pixel_data & 0x00FFFFFF);
319 rgb888 = (
u32)(pixel_data & 0x00FFFFFF);
384 if (*out_char_w == 0)
388 if (where.
y - baseline_offset < 0 || where.y - baseline_offset >=
LCDMaxY)
392 if (where.
x < 0 || where.
x + *out_char_w >=
LCDMaxX)
405 const u32 *font_data_copy = font->
data;
406 for (
u16 i = 0; i < index; i++)
410 bool pixel_has_value;
411 for (
u16 i = 0; i < *out_char_h; i++)
413 for (
u16 j = 0; j < *out_char_w; j++)
418 value = font_data_copy[i] & (0xFFFFFFFF >> (32 - *out_char_w));
422 pixel_has_value = (value >> (*out_char_w - j - 1)) & 0x1;
423 SET_POINT(mode, pixel_has_value ? txt_col : bg_col, where.
x + j, where.
y + i - baseline_offset);
449 u16 start_x = pos.
x, start_y = pos.
y;
456 bool no_more_space =
false;
457 u16 char_w, char_h, x_inc, y_inc;
458 while ((chr = *str) && !no_more_space)
482 total_height += y_inc;
487 no_more_space =
true;
490 x_diff = pos.
x - start_x;
494 cur_width = (x_diff + char_w) <
LCDMaxX ? (x_diff + char_w) :
LCDMaxX;
497 max_width = (cur_width > max_width) ? cur_width : max_width;
502 max_width = pos.
x - start_x;
517 if (!button || !mode)
536 return process_text(&label_as_text, pos, out_bbox, mode);
617 if (!comps || comps_sz == 0)
621 for (
u16 i = 0; i < comps_sz; i++)
624 if (current_comp_bbox->top_left.x < bbox.
top_left.
x)
625 bbox.
top_left.
x = current_comp_bbox->top_left.x;
627 if (current_comp_bbox->top_left.y < bbox.
top_left.
y)
628 bbox.
top_left.
y = current_comp_bbox->top_left.y;
651 comp = &obj->
comps[i];
#define RGB8_TO_RGB565(rgb)
Converts RGB (24 bit) into RGB565 (16 bit):
_PRIVATE bool process_rect(const LCD_Rect *const rect, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
_DECL_EXTERNALLY u16 LCDMaxY
_DECL_EXTERNALLY LCD_Color LCDCurrentBGColor
#define SET_POINT(mode, color, x, y)
_PRIVATE bool process_text(const LCD_Text *const text, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
Prints the string onto the screen, or calculates its dimensions without the overhead of printing.
_PRIVATE bool delete_button(const LCD_Button *const button, LCD_Coordinate pos)
_PRIVATE LCD_BBox get_union_bbox(LCD_Component *comps, u16 comps_sz)
#define SWAP(type, src, dst)
_PRIVATE bool process_button(const LCD_Button *const button, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
#define IS_MODE(mode, flag)
@ PRINT_CHR_ERR_SHOULD_NEWLINE
@ PRINT_CHR_ERR_OUT_OF_VERTICAL_BOUNDS
@ PRINT_CHR_ERR_NULL_PARAMS
_PRIVATE bool process_img_rle(const LCD_Image *const img, LCD_Coordinate pos, LCD_BBox *out_bbox, u8 mode)
bool __LCD_PROC_DoProcessObject(const LCD_Obj *const obj, LCD_BBox *out_bbox, u8 mode)
_DECL_EXTERNALLY LCD_Font LCDFontList[]
_DECL_EXTERNALLY u16 LCDMaxX
_DECL_EXTERNALLY u8 LCDFontListSize
_PRIVATE bool process_line(const LCD_Line *const line, LCD_BBox *out_bbox, u8 mode)
_PRIVATE PrintCharError print_char(u8 chr, const LCD_Font *const font, LCD_Coordinate where, u8 mode, LCD_Color txt_col, LCD_Color bg_col, u16 *out_char_w, u16 *out_char_h)
_PRIVATE bool process_circle(const LCD_Circle *const circle, LCD_BBox *out_bbox, u8 mode)
#define ASCII_FONT_MAX_VALUE
u32 LCD_Color
Represents a color in the RGB565 format.
#define ASCII_FONT_MIN_VALUE
LCD_Coordinate bottom_right
Used to store a drawable component of any type.
union LCD_Component::@0 object
const u16 * baseline_offsets
Represents a generic object, made up of 1 or more basic components, that are rendered on the screen.