color updates

Former-commit-id: 3ee8cfee2daa87cf8f312271eb6c38c632a7f3d5
Former-commit-id: d8d3304f23183f0b2452a24684887f16fa19ac43
This commit is contained in:
Nathan 2017-10-06 13:58:22 -05:00
parent aff3e48bbc
commit 0ad396a728
4 changed files with 33 additions and 24 deletions

View file

@ -6,6 +6,8 @@
#include "monokai.h" #include "monokai.h"
#include "SDL/SDL_gfxPrimitives.h" #include "SDL/SDL_gfxPrimitives.h"
#define CENTEROFFSET .375
void CROSSVP(double *v, double *u, double *w) void CROSSVP(double *v, double *u, double *w)
{ {
v[0] = u[1]*w[2] - u[2]*(w)[1]; v[0] = u[1]*w[2] - u[2]*(w)[1];
@ -54,7 +56,7 @@ int screenDist(double d) {
void screenCoords(int *outX, int *outY, double dx, double dy) { void screenCoords(int *outX, int *outY, double dx, double dy) {
*outX = (Modes.screen_width>>1) + ((dx>0) ? 1 : -1) * screenDist(dx); *outX = (Modes.screen_width>>1) + ((dx>0) ? 1 : -1) * screenDist(dx);
*outY = (Modes.screen_height * 0.4) + ((dy>0) ? 1 : -1) * screenDist(dy); *outY = (Modes.screen_height * CENTEROFFSET) + ((dy>0) ? 1 : -1) * screenDist(dy);
} }
int outOfBounds(int x, int y) { int outOfBounds(int x, int y) {
@ -212,22 +214,22 @@ void drawGrid()
int p10km = screenDist(10.0); int p10km = screenDist(10.0);
int p100km = screenDist(100.0); int p100km = screenDist(100.0);
hlineRGBA (game.screen, 0, Modes.screen_width, Modes.screen_height*0.4, 127, 127, 127, SDL_ALPHA_OPAQUE); hlineRGBA (game.screen, (Modes.screen_width>>1) - p100km, (Modes.screen_width>>1) + p100km, Modes.screen_height * CENTEROFFSET, grey.r, grey.g, grey.b, SDL_ALPHA_OPAQUE);
vlineRGBA (game.screen, Modes.screen_width>>1, 0, Modes.screen_height, 127, 127, 127, SDL_ALPHA_OPAQUE); vlineRGBA (game.screen, Modes.screen_width>>1, (Modes.screen_height * CENTEROFFSET) - p100km, (Modes.screen_height * CENTEROFFSET) + p100km, grey.r, grey.g, grey.b, SDL_ALPHA_OPAQUE);
if(AA) { if(AA) {
aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p1km, 249,38,114, SDL_ALPHA_OPAQUE); aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p1km, pink.r, pink.g, pink.b, 255);
aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p10km, 187,29,86, SDL_ALPHA_OPAQUE); aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p10km, pink.r, pink.g, pink.b, 195);
aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p100km, 125,19,57, SDL_ALPHA_OPAQUE); aacircleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height>>1, p100km, pink.r, pink.g, pink.b, 127);
} else { } else {
circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height*0.4, p1km, 249,38,114, SDL_ALPHA_OPAQUE); circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height * CENTEROFFSET, p1km, pink.r, pink.g, pink.b, 255);
circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height*0.4, p10km, 187,29,86, SDL_ALPHA_OPAQUE); circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height * CENTEROFFSET, p10km, pink.r, pink.g, pink.b, 195);
circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height*0.4, p100km, 125,19,57, SDL_ALPHA_OPAQUE); circleRGBA (game.screen, Modes.screen_width>>1, Modes.screen_height * CENTEROFFSET, p100km, pink.r, pink.g, pink.b, 127);
} }
drawString("1km", (Modes.screen_width>>1) + p1km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(249,38,114)); drawString("1km", (Modes.screen_width>>1) + (0.707 * p1km) + 5, (Modes.screen_height * CENTEROFFSET) + (0.707 * p1km) + 5, game.font, pink);
drawString("10km", (Modes.screen_width>>1) + p10km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(187,29,86)); drawString("10km", (Modes.screen_width>>1) + (0.707 * p10km) + 5, (Modes.screen_height * CENTEROFFSET) + (0.707 * p10km) + 5, game.font, pink);
drawString("100km", (Modes.screen_width>>1) + p100km + 5, (Modes.screen_height*0.4) + 5, game.font, setColor(125,19,57)); drawString("100km", (Modes.screen_width>>1) + (0.707 * p100km) + 5, (Modes.screen_height * CENTEROFFSET) + (0.707 * p100km) + 5, game.font, pink);
} }
void drawGeography() { void drawGeography() {
@ -245,10 +247,15 @@ void drawGeography() {
continue; continue;
} }
double d1 = sqrt(mapPoints_relative[(i - 1) * 2] * mapPoints_relative[(i - 1) * 2] + mapPoints_relative[(i - 1) * 2 + 1] * mapPoints_relative[(i - 1) * 2 + 1]);
double d2 = sqrt(mapPoints_relative[i * 2]* mapPoints_relative[i * 2] + mapPoints_relative[i * 2 + 1] * mapPoints_relative[i * 2 + 1]);
double alpha = 255.0 - 255.0 * (d1+d2) / (2 * 250);
if(AA) { if(AA) {
aalineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, SDL_ALPHA_OPAQUE); aalineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, (alpha < 0) ? 0 : (uint8_t) alpha);
} else { } else {
lineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, SDL_ALPHA_OPAQUE); lineRGBA(game.screen, x1, y1, x2, y2,purple.r,purple.g,purple.b, (alpha < 0) ? 0 : (uint8_t) alpha);
} }
} }
} }

View file

@ -1,7 +1,7 @@
#include "monokai.h" #include "monokai.h"
SDL_Color pink = {249,38,114,255}; SDL_Color pink = {249,38,114,255};
SDL_Color purple = {100,0,200,255}; SDL_Color purple = {160,0,255,255};
SDL_Color blue = {102,217,239,255}; SDL_Color blue = {102,217,239,255};
SDL_Color green = {166,226,46,255}; SDL_Color green = {166,226,46,255};
SDL_Color yellow = {253,250,31,255}; SDL_Color yellow = {253,250,31,255};

View file

@ -74,9 +74,9 @@ void drawStatusBox(int *left, int *top, char *label, char *message, SDL_Color co
} }
if(*left + labelWidth + messageWidth + PAD > Modes.screen_width) { if(*left + labelWidth + messageWidth + PAD > Modes.screen_width) {
if(*left + PAD < Modes.screen_width) { // if(*left + PAD < Modes.screen_width) {
boxRGBA(game.screen, *left, *top, Modes.screen_width - PAD, *top + game.messageFontHeight, darkGrey.r, darkGrey.g, darkGrey.b, SDL_ALPHA_OPAQUE); // boxRGBA(game.screen, *left, *top, Modes.screen_width - PAD, *top + game.messageFontHeight, darkGrey.r, darkGrey.g, darkGrey.b, SDL_ALPHA_OPAQUE);
} // }
*left = PAD; *left = PAD;
*top = *top - game.messageFontHeight - PAD; *top = *top - game.messageFontHeight - PAD;
} }
@ -110,8 +110,6 @@ void drawStatus() {
int left = PAD; int left = PAD;
int top = Modes.screen_height - game.messageFontHeight - PAD; int top = Modes.screen_height - game.messageFontHeight - PAD;
// drawStatusBox(&left, &top, "", "MENU", white);
char strLoc[20] = " "; char strLoc[20] = " ";
snprintf(strLoc, 20, "%3.3fN %3.3f%c", Modes.fUserLat, fabs(Modes.fUserLon),(Modes.fUserLon > 0) ? 'E' : 'W'); snprintf(strLoc, 20, "%3.3fN %3.3f%c", Modes.fUserLat, fabs(Modes.fUserLon),(Modes.fUserLon > 0) ? 'E' : 'W');
drawStatusBox(&left, &top, "GPS", strLoc, pink); drawStatusBox(&left, &top, "GPS", strLoc, pink);
@ -132,6 +130,8 @@ void drawStatus() {
snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0); snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0);
drawStatusBox(&left, &top, "sAvg", strSig, green); drawStatusBox(&left, &top, "sAvg", strSig, green);
drawStatusBox(&left, &top, "||||", "MENU", grey);
if(Status.closeCall != NULL) { if(Status.closeCall != NULL) {
char strSpeed[8] = " "; char strSpeed[8] = " ";
snprintf(strSpeed, 8, "%.0fkm/h", Status.closeCall->speed * 1.852); snprintf(strSpeed, 8, "%.0fkm/h", Status.closeCall->speed * 1.852);
@ -141,12 +141,14 @@ void drawStatus() {
snprintf(strAlt, 8, "%.0fm", Status.closeCall->altitude / 3.2828); snprintf(strAlt, 8, "%.0fm", Status.closeCall->altitude / 3.2828);
drawStatusBox(&left, &top, "alt", strAlt, white); drawStatusBox(&left, &top, "alt", strAlt, white);
drawStatusBox(&left, &top, "near", "", red);
if(strlen(Status.closeCall->flight)) { if(strlen(Status.closeCall->flight)) {
drawStatusBox(&left, &top, "id", Status.closeCall->flight, white); drawStatusBox(&left, &top, "id", Status.closeCall->flight, white);
} }
drawStatusBox(&left, &top, "near", "", red);
} }
drawStatusBox(&left, &top, "", "", black);
//drawStatusBox(&left, &top, "", "", black);
} }

View file

@ -1 +1 @@
b528f90e4ca7c8e232740b358694dd53c9c0a3cf b5241264afa7daa6932550d55fbf3c936b530c90