Skip to content

Commit 096f277

Browse files
committed
COMMON: draw line chart line with current foreground color
- removed unused os_color_depth setting
1 parent d03fa31 commit 096f277

File tree

8 files changed

+16
-35
lines changed

8 files changed

+16
-35
lines changed

src/common/blib_graph.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ void chart_draw(int x1, int y1, int x2, int y2, var_num_t *vals, int count,
897897
var_num_t *xvals, int xcount, int chart, int marks) {
898898
var_num_t lx, ly;
899899
char buf[32];
900-
int32_t color = 0;
900+
int32_t color = dev_fgcolor;
901901
int rx1 = x1;
902902

903903
// ready
@@ -1052,6 +1052,7 @@ void chart_draw(int x1, int y1, int x2, int y2, var_num_t *vals, int count,
10521052
case 5:
10531053
// line chart
10541054
// points
1055+
dev_settextcolor(color, 15);
10551056
if (chart == 5) {
10561057
for (int i = 0; i < count; i++) {
10571058
dev_setpixel(pts[i * 2], pts[i * 2 + 1]);
@@ -1061,6 +1062,7 @@ void chart_draw(int x1, int y1, int x2, int y2, var_num_t *vals, int count,
10611062
dev_line(pts[(i - 1) * 2], pts[(i - 1) * 2 + 1], pts[i * 2], pts[i * 2 + 1]);
10621063
}
10631064
}
1065+
dev_settextcolor(0, 15);
10641066

10651067
// draw marks
10661068
if (marks & 0x1) {
@@ -1094,19 +1096,12 @@ void chart_draw(int x1, int y1, int x2, int y2, var_num_t *vals, int count,
10941096
// draw rect
10951097
color = 0;
10961098
for (int i = 1; i < count; i++) {
1097-
if (os_color_depth > 2) {
1098-
dev_setcolor(color);
1099-
color++;
1100-
if (color >= 15) {
1101-
color = 0;
1102-
}
1103-
}
1099+
dev_setcolor(color);
1100+
color = (color + 1) % 16;
11041101
dev_rect(pts[(i - 1) * 2], pts[(i - 1) * 2 + 1], pts[i * 2] - 2, y2, 1);
11051102
}
11061103

1107-
if (os_color_depth > 2) {
1108-
dev_setcolor(color);
1109-
}
1104+
dev_setcolor(color);
11101105
dev_rect(pts[(count - 1) * 2], pts[(count - 1) * 2 + 1],
11111106
pts[(count - 1) * 2] + lx - 1, y2, 1);
11121107

@@ -1121,23 +1116,18 @@ void chart_draw(int x1, int y1, int x2, int y2, var_num_t *vals, int count,
11211116
int mx = pts[i * 2] + lx / 2 - fw / 2;
11221117
int my = pts[i * 2 + 1];
11231118

1124-
if (os_color_depth > 2) {
1125-
if (my - fh >= y1) {
1126-
dev_settextcolor(0, 15);
1119+
if (my - fh >= y1) {
1120+
dev_settextcolor(0, 15);
1121+
} else {
1122+
if (color >= 7 && color != 8) {
1123+
dev_settextcolor(0, color);
11271124
} else {
1128-
if (color >= 7 && color != 8) {
1129-
dev_settextcolor(0, color);
1130-
} else {
1131-
dev_settextcolor(15, color);
1132-
}
1133-
}
1134-
1135-
color++;
1136-
if (color >= 15) {
1137-
color = 0;
1125+
dev_settextcolor(15, color);
11381126
}
11391127
}
11401128

1129+
color = (color + 1) % 16;
1130+
11411131
if (my - fh >= y1) {
11421132
my -= fh;
11431133
}

src/common/device.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ void g_line(int x1, int y1, int x2, int y2, void (*dotproc) (int, int));
9999
*
100100
* @code
101101
* byte os_charset; // System's charset (see os_charset_codes)
102-
* uint32_t os_color_depth; // The number of bits of the supported colors
103-
* // (i.e.: 8 for 256 colors, 15 or 16 for 64K, 24 or 32 for 1.6M)
104102
* byte os_graphics; // Non-zero if the driver supports graphics
105103
* int os_graf_mx; // Graphic mode: screen width
106104
* int os_graf_my; // Graphic mode: screen height
@@ -128,8 +126,6 @@ enum os_charset_codes {
128126
extern byte os_charset;
129127

130128
extern byte os_color; // true if the output has real colors (256+ colors)
131-
extern uint32_t os_color_depth; // the number of bits of the supported colors
132-
// (ex: 8 for 256 colors, 15 or 16 for 64K, 24 or 32 for 1.6M)
133129
extern byte os_graphics; // non-zero if the driver supports graphics
134130
extern int os_graf_mx; // graphic mode: maximum x
135131
extern int os_graf_my; // graphic mode: maximum y

src/common/screen.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
c |= ((y > dev_Vy2) << 3); }
2828
#define CLIPIN(c) ((c & 0xF) == 0)
2929

30-
uint32_t os_color_depth = 16;
3130
byte os_graphics = 0; // CONSOLE
3231
int os_graf_mx = 80;
3332
int os_graf_my = 25;

src/platform/android/jni/runtime.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ void Runtime::runShell() {
482482
opt_command[0] = 0;
483483
opt_file_permitted = 1;
484484
os_graphics = 1;
485-
os_color_depth = 16;
486485
opt_mute_audio = 0;
487486

488487
_app->activity->callbacks->onContentRectChanged = onContentRectChanged;

src/platform/console/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ int main(int argc, char *argv[]) {
414414
opt_verbose = 0;
415415
opt_graphics = 1;
416416
os_graphics = 1;
417-
os_color_depth = 16;
418417

419418
console_init();
420419

src/platform/emcc/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ void init() {
5252
os_graf_mx = 1024;
5353
os_graf_my = 768;
5454
os_graphics = 1;
55-
os_color_depth = 16;
5655
opt_mute_audio = 0;
5756
}
5857

src/platform/fltk/runtime.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ bool System::getPen3() {
283283
return result;
284284
}
285285

286-
void System::completeKeyword(int index) {
286+
void System::completeKeyword(int index) const {
287287
// empty
288288
}
289289

src/platform/sdl/runtime.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ int Runtime::runShell(const char *startupBas, bool runWait, int fontScale, int d
269269
logEntered();
270270

271271
os_graphics = 1;
272-
os_color_depth = 16;
273272
opt_file_permitted = 1;
274273
opt_graphics = true;
275274
opt_nosave = true;
@@ -720,7 +719,7 @@ bool System::getPen3() {
720719
return (SDL_BUTTON(SDL_BUTTON_LEFT) && SDL_GetMouseState(&_touchCurX, &_touchCurY));
721720
}
722721

723-
void System::completeKeyword(int index) {
722+
void System::completeKeyword(int index) const {
724723
if (get_focus_edit() && isEditing()) {
725724
const char *help = get_focus_edit()->completeKeyword(index);
726725
if (help) {

0 commit comments

Comments
 (0)