using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace GrafikaLabki4 { public partial class Form1 : Form { private System.Drawing.Pen pen1 = new System.Drawing.Pen(Color.Black, 1); private System.Drawing.Pen pen2 = new System.Drawing.Pen(Color.Orange, 1); private System.Drawing.Pen pen3 = new System.Drawing.Pen(Color.Red, 1); private System.Drawing.Pen pen4 = new System.Drawing.Pen(Color.Green, 1); private System.Drawing.Brush brush1 = new System.Drawing.SolidBrush(Color.Red); private System.Drawing.Brush brush2 = new System.Drawing.SolidBrush(Color.Blue); public Form1() { InitializeComponent(); } private void Zad1_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); int srodekX = pictureBox1.Width / 2, srodekY = pictureBox1.Height / 2, maxX = pictureBox1.Width, maxY = pictureBox1.Height; gr.DrawLine(pen1, 0, srodekY, maxX, srodekY); gr.DrawLine(pen1, srodekX, 0, srodekX, maxY); int x0 = pictureBox1.Width / 2, y0 = pictureBox1.Height / 2, r = (pictureBox1.Height / 2) - 100; double teta = 0; int x1, y1, x2, y2; int ilePkt = 20; int.TryParse(textBox12.Text, out ilePkt); Point t = new Point(); int tmp; int.TryParse(textBox3.Text, out tmp); t.X = tmp; int.TryParse(textBox4.Text, out tmp); t.Y = tmp; Point[] punkty = new Point[ilePkt]; Point[] punktyN = new Point[ilePkt]; for (int i = 0; i < ilePkt; i++) { x1 = (int)(r * Math.Sin(teta) + x0); y1 = (int)(r * Math.Cos(teta) + y0); x2 = x1 + t.X; y2 = y1 - t.Y; punkty[i] = new Point(x1, y1); punktyN[i] = new Point(x2, y2); teta += ((360.0 / ilePkt) * Math.PI) / 180.0; } for (int i = 0; i < ilePkt; i++) { for (int j = 0; j < ilePkt - 1; j++) { gr.DrawLine(pen3, punkty[i], punkty[j]); gr.DrawLine(pen4, punktyN[i], punktyN[j]); } } pictureBox1.Image = bmp; } private void textBox2_TextChanged(object sender, EventArgs e) { } private void Zad2_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); int srodekX = pictureBox1.Width / 2, srodekY = pictureBox1.Height / 2, maxX = pictureBox1.Width, maxY = pictureBox1.Height; gr.DrawLine(pen1, 0, srodekY, maxX, srodekY); gr.DrawLine(pen1, srodekX, 0, srodekX, maxY); int x0 = pictureBox1.Width / 2, y0 = pictureBox1.Height / 2, r = (pictureBox1.Height / 2) - 100; double teta = 0; int x1, y1, x2, y2; int ilePkt = 20; int.TryParse(textBox13.Text, out ilePkt); double Sx, Sy; double.TryParse(textBox7.Text, out Sx); double.TryParse(textBox8.Text, out Sy); Point[] punkty = new Point[ilePkt]; Point[] punktyN = new Point[ilePkt]; for (int i = 0; i < ilePkt; i++) { x1 = (int)(r * Math.Sin(teta) + x0); y1 = (int)(r * Math.Cos(teta) + y0); x2 = (int)(x1 * Sx); y2 = (int)(y1 * Sy); punkty[i] = new Point(x1, y1); punktyN[i] = new Point(x2, y2); teta += ((360.0 / ilePkt) * Math.PI) / 180.0; } for (int i = 0; i < ilePkt; i++) { for (int j = 0; j < ilePkt - 1; j++) { gr.DrawLine(pen3, punkty[i], punkty[j]); gr.DrawLine(pen4, punktyN[i], punktyN[j]); } } pictureBox1.Image = bmp; } private void Zad3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); int srodekX = pictureBox1.Width / 2, srodekY = pictureBox1.Height / 2, maxX = pictureBox1.Width, maxY = pictureBox1.Height; gr.DrawLine(pen1, 0, srodekY, maxX, srodekY); gr.DrawLine(pen1, srodekX, 0, srodekX, maxY); int x0 = pictureBox1.Width / 2, y0 = pictureBox1.Height / 2, r = (pictureBox1.Height / 2) - 100; double teta = 0; double tetaP = 0; int tmp; int x1, y1, x2, y2; int ilePkt = 20; int.TryParse(textBox10.Text, out ilePkt); int.TryParse(textBox11.Text, out tmp); teta = tmp * Math.PI / 180.0; Point[] punkty = new Point[ilePkt]; Point[] punktyN = new Point[ilePkt]; for (int i = 0; i < ilePkt; i++) { x1 = (int)(r * Math.Sin(tetaP) + x0); y1 = (int)(r * Math.Cos(tetaP) + y0); x2 = (int)((r * Math.Sin(tetaP)) * Math.Cos(teta) - (r * Math.Cos(tetaP)) * Math.Sin(teta) + x0); y2 = (int)((r * Math.Cos(tetaP)) * Math.Cos(teta) + (r * Math.Sin(tetaP)) * Math.Sin(teta) + y0); punkty[i] = new Point(x1, y1); punktyN[i] = new Point(x2, y2); tetaP += ((360.0 / ilePkt) * Math.PI) / 180.0; } for (int i = 0; i < ilePkt; i++) { for (int j = 0; j < ilePkt - 1; j++) { gr.DrawLine(pen3, punkty[i], punkty[j]); gr.DrawLine(pen4, punktyN[i], punktyN[j]); } } pictureBox1.Image = bmp; } private void Zad4_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); int srodekX = pictureBox1.Width / 2, srodekY = pictureBox1.Height / 2, maxX = pictureBox1.Width, maxY = pictureBox1.Height; gr.DrawLine(pen1, 0, srodekY, maxX, srodekY); gr.DrawLine(pen1, srodekX, 0, srodekX, maxY); int x0 = pictureBox1.Width / 2, y0 = pictureBox1.Height / 2, r = (pictureBox1.Height / 2) - 100; double teta = 0; double tetaP = 0; int tmp; int x1, y1, x2, y2; int ilePkt = 20; int.TryParse(textBox1.Text, out ilePkt); int.TryParse(textBox2.Text, out tmp); teta = tmp * Math.PI / 180.0; Point t = new Point(); int.TryParse(textBox5.Text, out tmp); t.X = tmp; int.TryParse(textBox6.Text, out tmp); t.Y = tmp; Point[] punkty = new Point[ilePkt]; Point[] punktyN = new Point[ilePkt]; for (int i = 0; i < ilePkt; i++) { x1 = (int)(r * Math.Sin(tetaP) + x0); y1 = (int)(r * Math.Cos(tetaP) + y0); x2 = (int)((r * Math.Sin(tetaP)) * Math.Cos(teta) - (r * Math.Cos(tetaP)) * Math.Sin(teta) + x0 + t.X); y2 = (int)((r * Math.Cos(tetaP)) * Math.Cos(teta) + (r * Math.Sin(tetaP)) * Math.Sin(teta) + y0 - t.Y); punkty[i] = new Point(x1, y1); punktyN[i] = new Point(x2, y2); tetaP += ((360.0 / ilePkt) * Math.PI) / 180.0; } for (int i = 0; i < ilePkt; i++) { for (int j = 0; j < ilePkt - 1; j++) { gr.DrawLine(pen3, punkty[i], punkty[j]); gr.DrawLine(pen4, punktyN[i], punktyN[j]); } } pictureBox1.Image = bmp; } private void Form1_Load(object sender, EventArgs e) { } } }