+
+/* Draws meters along the diagonal for the x velocity */
+static void
+draw_meter_x(Display *dpy, Window window, GC draw_gc,
+ struct ball *balls, int i, int alone)
+{
+ XWindowAttributes xgwa;
+ int x1,x2,y,w1,w2,h;
+ XGetWindowAttributes (dpy, window, &xgwa);
+
+ /* set the width of the bars to use */
+ if(xgwa.height < BAR_SIZE*npoints)
+ {
+ y = i*(xgwa.height/npoints);
+ h = (xgwa.height/npoints) - 2;
+ }
+ else
+ {
+ y = BAR_SIZE*i;
+ h = BAR_SIZE - 2;
+ }
+
+ if(alone)
+ {
+ x1 = xgwa.width/2;
+ x2 = x1;
+ }
+ else
+ {
+ x1 = i*(h+2);
+ if(x1 < i)
+ x1 = i;
+ x2 = x1;
+ }
+
+ if(y<1) y=i;
+ if(h<1) h=1;
+
+ w1 = (int)(20*x_vels[i]);
+ w2 = (int)(20*balls[i].vx);
+ x_vels[i] = balls[i].vx;
+
+ if (w1<0) {
+ w1=-w1;
+ x1=x1-w1;
+ }
+ if (w2<0) {
+ w2=-w2;
+ x2=x2-w2;
+ }
+ XDrawRectangle(dpy,window,erase_gc,x1+(h+2)/2,y,w1,h);
+ XDrawRectangle(dpy,window,draw_gc,x2+(h+2)/2,y,w2,h);
+}
+
+/* Draws meters along the diagonal for the y velocity.
+ Is there some way to make draw_meter_x and draw_meter_y
+ one function instead of two without making them completely unreadable?
+*/
+static void
+draw_meter_y (Display *dpy, Window window, GC draw_gc,
+ struct ball *balls, int i, int alone)
+{
+ XWindowAttributes xgwa;
+ int y1,y2,x,h1,h2,w;
+ XGetWindowAttributes (dpy, window, &xgwa);
+
+ if(xgwa.height < BAR_SIZE*npoints){ /*needs to be height still */
+ x = i*(xgwa.height/npoints);
+ w = (xgwa.height/npoints) - 2;
+ }
+ else{
+ x = BAR_SIZE*i;
+ w = BAR_SIZE - 2;
+ }
+
+ if(alone)
+ {
+ y1 = xgwa.height/2;
+ y2 = y1;
+ }
+ else
+ {
+ y1 = i*(w+2);
+ if(y1 < i)
+ y1 = i;
+ y2 = y1;
+ }
+
+ if(x < 1) x = i;
+ if(w < 1) w = 1;
+
+ h1 = (int)(20*y_vels[i]);
+ h2 = (int)(20*balls[i].vy);
+ y_vels[i] = balls[i].vy;
+
+ if (h1<0) {
+ h1=-h1;
+ y1=y1-h1;
+ }
+ if (h2<0) {
+ h2=-h2;
+ y2=y2-h2;
+ }
+ XDrawRectangle(dpy,window,erase_gc,x,y1+(w+2)/2,w,h1);
+ XDrawRectangle(dpy,window,draw_gc,x,y2+(w+2)/2,w,h2);
+}
+
+
+/* Draws meters of the total speed of the balls */
+static void
+draw_meter_speed (Display *dpy, Window window, GC draw_gc,
+ struct ball *balls, int i)
+{
+ XWindowAttributes xgwa;
+ int y,x1,x2,h,w1,w2;
+ XGetWindowAttributes (dpy, window, &xgwa);
+
+ if(xgwa.height < BAR_SIZE*npoints)
+ {
+ y = i*(xgwa.height/npoints);
+ h = (xgwa.height/npoints) - 2;
+ }
+ else{
+ y = BAR_SIZE*i;
+ h = BAR_SIZE - 2;
+ }
+
+ x1 = 0;
+ x2 = x1;
+
+ if(y < 1) y = i;
+ if(h < 1) h = 1;
+
+ w1 = (int)(5*speeds[i]);
+ w2 = (int)(5*(balls[i].vy*balls[i].vy+balls[i].vx*balls[i].vx));
+ speeds[i] = balls[i].vy*balls[i].vy+balls[i].vx*balls[i].vx;
+
+ XDrawRectangle(dpy,window,erase_gc,x1,y,w1,h);
+ XDrawRectangle(dpy,window,draw_gc, x2,y,w2,h);
+}
+