Írjunk programot, amely 3 pontból úgy rajzol 10 vonalat, hogy azok találkozzanak.
A feladat megoldása
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = this.CreateGraphics();
int fw = this.ClientSize.Width;
int fh = this.ClientSize.Height;
g.DrawLine(Pens.Blue, new Point(30, 50),
new Point(fw - 30, 50));
for (int i = 0; i <= 10; i++)
g.DrawLine(Pens.Blue, new Point(30, 50),
new Point(30 + i * (fw - 60) / 10, fh - 50));
for (int i = 0; i <= 10; i++)
g.DrawLine(Pens.Green, new Point(fw - 30, 50),
new Point(30 + i * (fw - 60) / 10, fh - 50));
for (int i = 0; i < 10; i++)
g.DrawLine(Pens.Red, new Point(fw/2, 50),
new Point(30 + i * (fw - 60) / 10, fh - 50));
}
private void Form1_Resize(object sender, EventArgs e)
{
Refresh();
}
A program futási eredménye: