forked from lc-soft/LCUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline.c
115 lines (107 loc) · 2.61 KB
/
line.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <LCUI_Build.h>
#include <LCUI/LCUI.h>
#include <LCUI/graph.h>
void Graph_DrawHorizLine(LCUI_Graph *graph, LCUI_Color color, int size,
LCUI_Pos start, int len)
{
int y, x;
LCUI_Rect area;
LCUI_Graph *des;
des = Graph_GetQuote(graph);
Graph_GetValidRect(graph, &area);
start.x = area.x + start.x;
start.y = area.y + start.y;
if (start.x < area.x) {
len -= (area.x - start.x);
start.x = area.x;
}
if (len > area.x + area.width) {
len = area.x + area.width;
}
if (start.y < area.y) {
size -= (area.y - start.y);
start.y = area.y;
}
if (start.y + size > area.y + area.height) {
size = area.y + area.height - start.y;
}
if (des->color_type == LCUI_COLOR_TYPE_ARGB) {
LCUI_ARGB *pPixel, *pRowPixel;
pRowPixel = des->argb + start.y*des->width + start.x;
for (y = 0; y < size; ++y) {
pPixel = pRowPixel;
for (x = 0; x < len; ++x) {
pPixel->b = color.blue;
pPixel->g = color.green;
pPixel->r = color.red;
pPixel->a = 255;
++pPixel;
}
pRowPixel += des->width;
}
} else {
uchar_t *pByte, *pRowByte;
pRowByte = des->bytes + start.y*des->bytes_per_row + start.x * 3;
for (y = 0; y < size; ++y) {
pByte = pRowByte;
for (x = 0; x < len; ++x) {
*pByte++ = color.blue;
*pByte++ = color.green;
*pByte++ = color.red;
}
pRowByte += des->bytes_per_row;
}
}
}
LCUI_API void Graph_DrawVertiLine(LCUI_Graph *graph, LCUI_Color color,
int size, LCUI_Pos start, int len)
{
int y, x;
LCUI_Rect area;
LCUI_Graph *des;
des = Graph_GetQuote(graph);
Graph_GetValidRect(graph, &area);
start.x = area.x + start.x;
start.y = area.y + start.y;
if (start.x < area.x) {
size -= (area.x - start.x);
start.x = area.x;
}
if (start.x + size > area.x + area.width) {
size = area.x + area.width - start.x;
}
if (start.y < area.y) {
len -= (area.y - start.y);
start.y = area.y;
}
if (start.y + len > area.y + area.height) {
len = area.y + area.height - start.y;
}
if (des->color_type == LCUI_COLOR_TYPE_ARGB) {
LCUI_ARGB *pPixel, *pRowPixel;
pRowPixel = des->argb + start.y*des->width + start.x;
for (y = 0; y < len; ++y) {
pPixel = pRowPixel;
for (x = 0; x < size; ++x) {
pPixel->b = color.blue;
pPixel->g = color.green;
pPixel->r = color.red;
pPixel->a = 255;
++pPixel;
}
pRowPixel += des->width;
}
} else {
uchar_t *pByte, *pRowByte;
pRowByte = des->bytes + start.y*des->bytes_per_row + start.x * 3;
for (y = 0; y < len; ++y) {
pByte = pRowByte;
for (x = 0; x < size; ++x) {
*pByte++ = color.blue;
*pByte++ = color.green;
*pByte++ = color.red;
}
pRowByte += des->bytes_per_row;
}
}
}