Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 linia
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Bitmap pom = new Bitmap(pictureBox1.Width, pictureBox1.Height);
- int y2, y1, x1, x2;
- x1 = (int)numericUpDown1.Value;
- x2 = (int)numericUpDown3.Value;
- y1 = (int)numericUpDown2.Value;
- y2 = (int)numericUpDown4.Value;
- float m, y,dy, dx;
- int start = System.Environment.TickCount;
- dy = y2 - y1;
- dx = x2 - x1;
- m = dy / dx;
- for (int i = 0; i < 10000; i++)
- {
- y = y1;
- for (int x = x1; x <= x2; x++)
- {
- pom.SetPixel(x, (int)Math.Round(y), Color.Red);
- y += m;
- }
- }
- pictureBox1.Image = pom;
- int stop = System.Environment.TickCount;
- MessageBox.Show("Obliczenia przyrostowe trwały " + (stop - start).ToString() + "ms");
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Bitmap pom = new Bitmap(pictureBox1.Width, pictureBox1.Height);
- int dx, dy,incrE, incrNE, d ,x ,y;
- int x2, x1, y2, y1;
- x1 = (int)numericUpDown1.Value;
- x2 = (int)numericUpDown3.Value;
- y1 = (int)numericUpDown2.Value;
- y2 = (int)numericUpDown4.Value;
- int start = System.Environment.TickCount;
- dx = x2 - x1;
- dy = y2 - y1;
- d = 2 * dy - dx;
- incrE = dy * 2;
- incrNE = (dy - dx) * 2;
- for (int i = 0; i < 10000; i++)
- {
- x = x1;
- y = y1;
- pom.SetPixel(x, y, Color.Aqua);
- while (x < x2)
- {
- if (d <= 0)
- {
- d += incrE;
- x++;
- }
- else
- {
- d += incrNE;
- x++;
- y++;
- }
- pom.SetPixel(x, y, Color.Aqua);
- }
- }
- int stop = System.Environment.TickCount;
- pictureBox1.Image = pom;
- MessageBox.Show("Obliczenia przyrostowe trwały " + (stop - start).ToString() + "ms");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement