Oscilloscope

Posted By: carlpa

Oscilloscope - 01/14/14 04:18

I am working to develop a program to demonstrate physiologic effects using a spring model. Part of the output will be 3 - 5 waveforms as if looking at an oscilloscope. I was considering the use of particles or changing pixels on a bmap. I do not wish to reinvent the wheel. Does anyone have a solution or the ability to direct me to a solution. My students, residents, fellows and I will be very grateful. Thank you in advance.
Posted By: oliver2s

Re: Oscilloscope - 01/14/14 10:19

I would do this with the "draw_line" (http://www.conitec.net/beta/draw_line.htm) instructions in combination with some simple math function to create the coordinates.
Posted By: oliver2s

Re: Oscilloscope - 01/14/14 10:32

Here I made small example:

Code:
function waveform1(var x)
{
	return sinv(x*10)*20 + screen_size.y/2 - 10;	
}

void main()
{
	wait(1);
	
	screen_color.red=1;
	screen_color.green=1;
	screen_color.blue=1;

	while(1)
	{
		draw_line(nullvector,NULL,100);
		var x; for(x=0;x<screen_size.x;x++)
		{			
			var y=waveform1(x);
			
			draw_line(vector(x,y,0),vector(255,255,255),100);
		}
		
		wait(1);	
	}
}

Posted By: carlpa

Re: Oscilloscope - 01/15/14 00:09

Works well. Thank you very much. Will build your routine in my project. I might return if success eludes me.
© 2024 lite-C Forums