محرر و مترجم أكواد أون لاين لـ 15 لغة برمجة مختلفة من شركة ليندا
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 Computer_Graghic_Project
{
public partial class Circle : Form
{
public Circle()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap pb3 = new Bitmap(pictureBox1.Width, pictureBox1.Height);
dataGridView1.Rows.Clear();
dataGridView1.ColumnCount = 4;
dataGridView1.Columns[0].Name = "k";
dataGridView1.Columns[1].Name = "p1k";
dataGridView1.Columns[2].Name = "xk+1";
dataGridView1.Columns[3].Name = "yk+1";
int xcenter = pictureBox1.Width / 2;
int ycenter = pictureBox1.Height / 2;
int r = int.Parse(textBox1.Text);
int x = r, y = 0;
int p0 = 1 - r;
int P = p0;
dataGridView1.Rows.Add(0, P, x, y);
int c = 1;
while (x > y)
{
pb3.SetPixel(xcenter + x, ycenter + y, Color.Red);
pb3.SetPixel(xcenter - x, ycenter + y, Color.Red);
pb3.SetPixel(xcenter + x, ycenter - y, Color.Red);
pb3.SetPixel(xcenter - x, ycenter - y, Color.Red);
pb3.SetPixel(xcenter + y, ycenter + x, Color.Red);
pb3.SetPixel(xcenter - y, ycenter + x, Color.Red);
pb3.SetPixel(xcenter + y, ycenter - x, Color.Red);
pb3.SetPixel(xcenter - y, ycenter - x, Color.Red);
if (P <= 0)
{
y++;
P = P + 2 * (y + 1) + 1;
dataGridView1.Rows.Add(c, P, x, y);
}
else
{
x--;
y++;
P = P + 2 * (y + 1) - 2 * (x - 1) + 1;
dataGridView1.Rows.Add(c, P, x, y);
}
}
pictureBox1.Image = pb3;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Form1 f4 = new Form1();
this.Hide();
f4.Show();
}
}
}
التعليقات