PDA

View Full Version : Wanted graphic source for osciliscope


dale
02-28-2004, 05:14 AM
Hello,

I am looking for a C source code for something
that will put sinewaves on my dos computer
when it boot's up.
I just like the idea of having an osciliscope
or several sine waves, run across the screen
after dos boots up, I think It looks cool.

So far I have been able to find the following
program, from a C Text Book, But I can't
get any more Sine Waves than 2 on the screen.

Does anyone know where I can find C source code
to put something like an osciliscope or several
sine waves on the screen. That is what I am looking
for.

Thank You
Dale




/*
Sine.c
plots sine function, demonstrates putpixel()
wrinten for Turbo C++
Taken From
The Waite Group's
C Programming Using Turbo C++
Second Edition
page 372
In the book it is called plot.c,
*/

#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <conio.h>
#include <math.h>
#include <time.h>
#include <string.h>


void main(void)
{
int driver, mode; /* graphics driver and mode */
double angle, sinofA, cosofA; /* angle and sin of angle */
int t, u, v, w, x, y, z; /* screen coordinates */


w = 0;
t = 0;


registerbgidriver(EGAVGA_driver);


driver = DETECT; /* auto detect
initialize graphics */

initgraph(&driver, &mode, "" );

/* initgraph(&driver, &mode, "c:\\tc2\\bgi"); */
/* line( 0, 100, 200, 100); */


for( z = 0 ; z < 1000 ; z++){

v = 600;

t = t + 1;

if( t <= 100)
w++;

if( t > 100)
w--;

if( t >= 200 )
t = 0;


for( x=0 ; x < v ; x++ )
{
angle = ( (double)x / 200 * ( 2 * 3.14159265) );
sinofA = sin(angle);
cosofA = cos(angle);
y = 250 - w * sinofA ;
putpixel(x, y, LIGHTGREEN);
y = 250 - w * cosofA ;
putpixel(x, y, LIGHTBLUE);
};


for( u=0 ; u < 10000 ; u++);


for( x=0 ; x < v ; x++ )
{
angle = ( (double)x / 200 * ( 2 * 3.14159265) );
sinofA = sin(angle);
cosofA = cos(angle);
y = 250 - w * sinofA ;
putpixel(x, y, BLACK);
y = 250 - w * cosofA ;
putpixel(x, y, BLACK);
};



}; /* end of 1st For Statement */

closegraph();
}

/*
angle 0.0, 1.6, 3.1, 4.7, 6.2
sin 0.0 1.0 0.0 -1.0 0.0
x 0 50 100 150 199
y 100 200 100 0 96

*/


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service