Write a simple C program that creates an image of the sin fu

Write a simple C# program that creates an image of the sin function. file format: pgm (P2 grey) file name: out.pgm sin function: width/domain/x:[0..2Pi] y: real numbers [1.0...+1.01] image: width: 500 pixels ({0, .., 499) height: 250 pixels (repeat values from sin 250 times) pixel values: integers {0, ..., 255)

Solution

Answer:

using System.*;

class SineImageCurve:Form
{
public static void Main()
{
Application.Run(new SineImageCurve());
}
public SineImageCurve()
{
Text = \"Sine Image Curve\";
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs read)
{
workpage(read.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
}
protected void workpage(Graphics image_graphic, Color value_color, int x_value, int y_value)
{
PointF[] input = new PointF[x_value];

for (int i = 0; i < x_value; i++)
{
input[i].X = i;
input[i].Y = y_value / 2 * (1 -(float)
Math.Sin(i * 2 * Math.PI / (x_value - 1)));
}
image_graphic.DrawLines(new Pen(value_color), input);
}
}

 Write a simple C# program that creates an image of the sin function. file format: pgm (P2 grey) file name: out.pgm sin function: width/domain/x:[0..2Pi] y: rea

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site