view src/rovascope/drawing.c @ 611:3f7a52adfe0e trunk

[svn] merge recent changes from yaz's branch. - stable shoutcast playback. - tag handling improvement. - view track detail on streaming won't crash. (disabled.) - filepopup for streaming is partially supported. filepopup displays track name and stream name, but not updated automatically.
author yaz
date Tue, 06 Feb 2007 12:11:42 -0800
parents 290588854a9d
children
line wrap: on
line source

#include <math.h>

#include "paranormal.h"
#include "actuators.h"
#include "pn_utils.h"

extern SDL_Surface *screen;

void
pn_draw_dot (guint x, guint y, guchar value)
{
  if (x > pn_image_data->width || x < 0 || y > pn_image_data->height || y < 0)
    return;

  pn_image_data->surface[0][PN_IMG_INDEX(x, y)] = value;
}

void
pn_draw_line (guint _x0, guint _y0, guint _x1, guint _y1, guchar value)
{
  gint x0 = _x0;
  gint y0 = _y0;
  gint x1 = _x1;
  gint y1 = _y1;

  gint dx = x1 - x0;
  gint dy = y1 - y0;

  pn_draw_dot(x0, y0, value);

  if (dx != 0)
    {
      gfloat m = (gfloat) dy / (gfloat) dx;
      gfloat b = y0 - m * x0;

      dx = (x1 > x0) ? 1 : - 1;
      while (x0 != x1)
        {
          x0 += dx;
          y0 = m * x0 + b;

          pn_draw_dot(x0, y0, value);
        }
    }
}