Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!csn!ccncsu!longs.LANCE.ColoState.EDU!steves From: steves@longs.LANCE.ColoState.EDU (Steve Smith) Newsgroups: comp.lang.c Subject: graphics challenge..... Message-ID: <14318@ccncsu.ColoState.EDU> Date: 17 Apr 91 20:47:57 GMT References: <3727@inews.intel.com> <3465@litchi.bbn.com> <1991Apr4.215605.2801@syssoft.com> <1991Apr7.064003.8552@athena.mit.edu> Sender: news@ccncsu.ColoState.EDU Reply-To: steves@longs.LANCE.ColoState.EDU (Steve Smith) Organization: Colorado State U. Center for Computer Assisted Engineering. Lines: 66 I'm trying to build a mini program that reads in an ascii data file and plots the data on the screen. I have the program reading in the data just fine and in the correct order. The problem is getting the data points to plot out correctly... here is what the code looks like: #include #include main() { int graphdriver = DETECT, graphmode, pen, x,y; int maxx, maxy, maxvalue, scale; /* more stuff */ getmaxx(); getmaxy(); /* get the name of the file etc.... */ { initgraph(&graphdriver, &graphmode, "c:\\tc"); setcolor(WHITE); } do { fgets(buffer, 6000, infile); sscanf(buffer, " %d %d %d ", &pen, &x, &y); /* HERE'S THE PROBLEM */ scale = (getmaxx()/maxvalue); /* maxvalue is the maximum value of any data point in the data.fil*/ /* scale should set a scale for the specific screen size */ xp = abs((x - getmaxx())) * 1/scale; /* xp, yp are the new points to fit within the screen area */ yp = abs((y - getmaxy())) * 1/scale; /* Should scale the values for any specific graphics type */ if (pen == 0) moveto(xp,yp); else { lineto(xp,yp); } } while (fgets(buffer, 6000, infile) != NULL); /* more ending code */ The code needs to take into account any data value and then use the scale to fit it within a specific graphics screen. So far I get the graphic, but a data file to plot a box doesn't even look close to a box in shape.? Is there an easy and slick way to handle all this? Thanks in advance Steve Smith Colorado State University Engineering