summaryrefslogtreecommitdiff
path: root/i/serialplot/serialplot_sdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'i/serialplot/serialplot_sdl.c')
-rw-r--r--i/serialplot/serialplot_sdl.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/i/serialplot/serialplot_sdl.c b/i/serialplot/serialplot_sdl.c
index 22013f8..958736e 100644
--- a/i/serialplot/serialplot_sdl.c
+++ b/i/serialplot/serialplot_sdl.c
@@ -1,38 +1,65 @@
#include "serialplot_sdl.h"
void
-draw (int melt, int n, int vals[])
+draw (int melt, int n, int vals[], double scale[],int position[])
{
int i;
Uint32 color;
static const Uint8 colors[][3] =
{
- { 0, 255, 0 },
- { 255, 0, 255 },
- { 255, 255, 0 },
- { 255, 0, 0 },
- { 0, 255, 255 },
- { 255, 255, 255 },
+ { 0, 0, 255 }, // bleu
+ { 0, 255, 0 }, // vert
+ { 255, 0, 0 }, // rouge
+ { 255, 0, 255 }, // mauve
+ { 255, 255, 0 }, // jaune
+ { 0, 255, 255 }, // cyan
+ { 255, 255, 255 }, // blanc
};
int c = 0;
static int x = 0;
int y;
- int ymin = 0;
- int ystep = screen->h / (melt ? 1 : n);
+ //int ymin = 0;
+ /* ystep = la hauteur de la surface / soit par le nb de courbe à
+ * affiché ou par 1 */
+ //int ystep = screen->h / (melt ? 1 : n);
x = (x + 1) % screen->w;
/* Vérouille la surface pour y ecrire directement. */
if (SDL_MUSTLOCK (screen)) SDL_LockSurface (screen);
clearcol (x);
for (i = 0; i < n; i++)
{
- double v = vals[i];
- y = ymin + ystep / 2 - v * ystep / 2;
- y = y < 0 ? ymin : (y >= ymin + ystep ? ymin + ystep - 1 : y);
- color = SDL_MapRGB (screen->format, colors[c][0], colors[c][1], colors[c][2]);
+
+ int v = vals[i];
+ y = screen->h / 2 - v * scale[i] + position[i];
+ /* saturation des extremes */
+ if (y<0)
+ y=0;
+ else
+ if(y > screen->h)
+ y = screen->h;
+ color = SDL_MapRGB (screen->format,
+ colors[c][0],
+ colors[c][1],
+ colors[c][2]);
+ putpixel(x,y,color);
+ y = screen->h / 2 + position[i];
+ color = SDL_MapRGB (screen->format,
+ colors[6][0],
+ colors[6][1],
+ colors[6][2]);
putpixel(x,y,color);
- if (!melt)
- ymin += ystep;
c = (c + 1) % (sizeof (colors) / sizeof (colors[0]));
+ // double v = vals[i];
+// y = ymin + ystep / 2 - v * ystep / 2;
+// y = y < 0 ? ymin : (y >= ymin + ystep ? ymin + ystep - 1 : y);
+// color = SDL_MapRGB (screen->format, colors[c][0], colors[c][1], colors[c][2]);
+// putpixel(x,y,color);
+// if (!melt)
+// {
+// ymin += ystep;
+// }
+//
+// c = (c + 1) % (sizeof (colors) / sizeof (colors[0]));
}
if (SDL_MUSTLOCK (screen)) SDL_UnlockSurface (screen);
}