diff --git a/draw.c b/draw.c index d0cd543..19e78dc 100644 --- a/draw.c +++ b/draw.c @@ -48,6 +48,23 @@ SDL_Color signalToColor(int signal) { return planeColor; } +SDL_Color lerpColor(SDL_Color aColor, SDL_Color bColor, float factor) { + if(factor > 1.0f) { + factor = 1.0f; + } + + if(factor < 0.0f) { + factor = 0.0f; + } + + SDL_Color out; + out.r = (1.0f - factor) * aColor.r + factor * bColor.r; + out.g = (1.0f - factor) * aColor.g + factor * bColor.g; + out.b = (1.0f - factor) * aColor.b + factor * bColor.b; + + return out; +} + SDL_Color hsv2SDLColor(double h, double s, double v) { double hh, p, q, t, ff; @@ -519,9 +536,11 @@ void drawPolys(QuadTree *tree, double screen_lat_min, double screen_lat_max, dou double d2 = dx* dx + dy * dy; - double alpha = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist); + double factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist); - lineRGBA(appData.renderer, x1, y1, x2, y2, alpha * purple.r + (1.0-alpha) * blue.r, alpha * purple.g + (1.0-alpha) * blue.g, alpha * purple.b + (1.0-alpha) * blue.b, 255 * alpha); + SDL_Color lineColor = lerpColor(blue, purple, factor); + + lineRGBA(appData.renderer, x1, y1, x2, y2, lineColor.r, lineColor.g, lineColor.b, 255); prevPoint = currentPoint; currentPoint = currentPoint->next; @@ -881,17 +900,6 @@ void drawMap() { pxFromLonLat(&dx, &dy, p->lon, p->lat); screenCoords(&x, &y, dx, dy); - - if((int)(now - p->seen) > DISPLAY_ACTIVE) { - planeColor = grey; - } else { - planeColor = green; - //srand(p->addr); - // planeColor = hsv2SDLColor(255.0 * (double)rand()/(double)RAND_MAX, 255.0, 200.0); - //planeColor = signalToColor((int)(255.0f * (float)rand()/(float)RAND_MAX)); - //fprintf("%d %d %d\n", planeColor.r, planeColor.g, planeColor.b); - } - if(p->created == 0) { p->created = mstime(); } @@ -901,7 +909,7 @@ void drawMap() { circleRGBA(appData.renderer, x, y, 500 - age_ms, 255,255, 255, (uint8_t)(255.0 * age_ms / 500.0)); } else { if(MODES_ACFLAGS_HEADING_VALID) { - int usex = x; + int usex = x; int usey = y; if(p->seenLatLon > p->oldSeen[p->oldIdx]) { @@ -918,6 +926,34 @@ void drawMap() { usey = y + (mstime() - p->msSeenLatLon) * vely; } + if((usex - appData.touchx) * (usex - appData.touchx) + (usey - appData.touchy) * (usey - appData.touchy) < 900) { + selectedPlane = p; + } + + if(p == selectedPlane) { + appData.centerLon += 0.1 * (p->lon - appData.centerLon); + appData.centerLat += 0.1 * (p->lat - appData.centerLat); + + + thickLineRGBA(appData.renderer, x - 40, y - 40, x - 10, y - 40, 4, pink.r, pink.g, pink.b, 255); + thickLineRGBA(appData.renderer, x - 40, y - 40, x - 40, y - 10, 4, pink.r, pink.g, pink.b, 255); + + thickLineRGBA(appData.renderer, x + 40, y - 40, x + 10, y - 40, 4, pink.r, pink.g, pink.b, 255); + thickLineRGBA(appData.renderer, x + 40, y - 40, x + 40, y - 10, 4, pink.r, pink.g, pink.b, 255); + + thickLineRGBA(appData.renderer, x + 40, y + 40, x + 10, y + 40, 4, pink.r, pink.g, pink.b, 255); + thickLineRGBA(appData.renderer, x + 40, y + 40, x + 40, y + 10, 4, pink.r, pink.g, pink.b, 255); + + thickLineRGBA(appData.renderer, x - 40, y + 40, x - 10, y + 40, 4, pink.r, pink.g, pink.b, 255); + thickLineRGBA(appData.renderer, x - 40, y + 40, x - 40, y + 10, 4, pink.r, pink.g, pink.b, 255); + planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE); + } else { + planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE); + } + + // if((int)(now - p->seen) > DISPLAY_ACTIVE) { + // planeColor = grey; + // } if(outOfBounds(x,y)) { drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor); @@ -950,15 +986,15 @@ void drawMap() { if(appData.touchx && appData.touchy) { - int radius = (mstime() - appData.touchDownTime); - int alpha = 255 - (int)(0.5 * (mstime() - appData.touchDownTime)); + int radius = .25 * (mstime() - appData.touchDownTime); + int alpha = 128 - (int)(0.5 * (mstime() - appData.touchDownTime)); if(alpha < 0 ) { alpha = 0; appData.touchx = 0; appData.touchy = 0; } - circleRGBA(appData.renderer, appData.touchx, appData.touchy, radius, white.r, white.g, white.b, alpha); + filledCircleRGBA(appData.renderer, appData.touchx, appData.touchy, radius, white.r, white.g, white.b, alpha); } } diff --git a/draw.o.REMOVED.git-id b/draw.o.REMOVED.git-id index 8f54ef4..127f6f3 100644 --- a/draw.o.REMOVED.git-id +++ b/draw.o.REMOVED.git-id @@ -1 +1 @@ -1d914216fcda8f2b793acf12bfbfddfb24809c94 \ No newline at end of file +d08aaa37cf2b39ef11671ed4f318ae82fcf0c1dd \ No newline at end of file diff --git a/font.o b/font.o index 9acfc71..3f98783 100644 Binary files a/font.o and b/font.o differ diff --git a/init.o b/init.o index 7d18cc4..82dcfa3 100644 Binary files a/init.o and b/init.o differ diff --git a/input.c b/input.c index 8ccf87a..4fe055d 100644 --- a/input.c +++ b/input.c @@ -83,17 +83,10 @@ void getInput() case SDL_FINGERUP: if(mstime() - appData.touchDownTime < 30) { - //latLonFromScreenCoords(&(appData.touchLat), &(appData.touchLon), event.tfinger.x, event.tfinger.y); - // double scale_factor = (appData.screen_width > appData.screen_height) ? appData.screen_width : appData.screen_height; - - // double dx = -1.0 * (0.75*(double)appData.screen_width / (double)appData.screen_height) * appData.screen_width * event.tfinger.x * appData.maxDist / (0.95 * scale_factor * 0.5); - // double dy = 1.0 * appData.screen_height * event.tfinger.y * appData.maxDist / (0.95 * scale_factor * 0.5); - - // appData.touchLat = dy * (1.0/6371.0) * (180.0f / M_PI); - - // appData.touchLon = dx * (1.0/6371.0) * (180.0f / M_PI) / cos(((appData.centerLat)/2.0f) * M_PI / 180.0f); appData.touchx = appData.screen_width * event.tfinger.x; appData.touchy = appData.screen_height * event.tfinger.y; + selectedPlane = NULL; + } else { appData.touchx = 0; appData.touchy = 0; diff --git a/input.o.REMOVED.git-id b/input.o.REMOVED.git-id index 360c152..896993b 100644 --- a/input.o.REMOVED.git-id +++ b/input.o.REMOVED.git-id @@ -1 +1 @@ -4014ada04a2708aebb111395550edf352c684f96 \ No newline at end of file +71b217637379d15bac063de1731f31a46620dce5 \ No newline at end of file diff --git a/list.o b/list.o index dfda3c3..bf26832 100644 Binary files a/list.o and b/list.o differ diff --git a/monokai.o b/monokai.o index f4fa057..a21da71 100644 Binary files a/monokai.o and b/monokai.o differ diff --git a/planeObj.o b/planeObj.o index 55fc516..1be9b9e 100644 Binary files a/planeObj.o and b/planeObj.o differ diff --git a/status.o.REMOVED.git-id b/status.o.REMOVED.git-id index b903e78..17750e5 100644 --- a/status.o.REMOVED.git-id +++ b/status.o.REMOVED.git-id @@ -1 +1 @@ -ec8f0fb7706c5fa30afa98ef72cf1c6277615e5c \ No newline at end of file +006a8fe10b2ac3777a05e5056d4166533ad2fae5 \ No newline at end of file diff --git a/structs.h b/structs.h index 6ae020c..45b64d7 100644 --- a/structs.h +++ b/structs.h @@ -86,6 +86,9 @@ struct planeObj { struct planeObj *planes; + +struct planeObj *selectedPlane; + struct { double msgRate; double avgSig; diff --git a/view1090.REMOVED.git-id b/view1090.REMOVED.git-id index 267e656..6735ea2 100644 --- a/view1090.REMOVED.git-id +++ b/view1090.REMOVED.git-id @@ -1 +1 @@ -4c1cc2ef49ee01e71918440dd30dd506c50f2a13 \ No newline at end of file +607b9efc8cc81bbdd0c6f524632fc9b69ab1e244 \ No newline at end of file diff --git a/view1090.o.REMOVED.git-id b/view1090.o.REMOVED.git-id index 55d52d1..c48ad66 100644 --- a/view1090.o.REMOVED.git-id +++ b/view1090.o.REMOVED.git-id @@ -1 +1 @@ -c32a44e5918f8a87926408a39f094f258c9f76e6 \ No newline at end of file +188de208d70a8a746cda5dd29c243ac3053a9c0c \ No newline at end of file