Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

UNIVERSIDAD AUTÓNOMA

DE CHIAPAS

FACULTAD DE CONTADURÍA Y ADMINISTRACIÓN


CAMPUS 1

LIC. SISTEMAS COMPUTACIONALES

6° J

GRAFICACIÓN

PROGRAMA CIRCULO RELLENO

JOSE JULIAN CRUZ GONZÁLEZ - A190394


PAOLA OROZCO CARRION - A190490
ERICK CORZO CRUZ - A190563
DIELY LLUDIANA DÍAZ DÍAZ - A190554

MTRO. LUIS MANUEL SANDOVAL ZUÑIGA

TUXTLA GUTIÉRREZ, CHIAPAS

MARTES, 14 DE FEBRERO DE 2023

Imágenes de pantalla circulo relleno


 (Xc,Yc) = (100,100) el radio R=51

(Xc,Yc) = (50,50) el radio R= 9

(Xc,Yc) = (200,150) el radio R=91


Diagrama de Flujo
Programa Fuente
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 Circulo
{
public partial class Form1 : Form
{
private Pen lapiz, lapiz2;
private Graphics punto, vector;
int[] cx = new int[10000];
int[] cy = new int[10000];
int z = 1;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
textBox1.Text = "0";
textBox2.Text = "0";
textBox3.Text = "0";
textBox4.Text = "Pk\t-\tX\t-\tY \r\n";
textBox5.Text = "Y \t - \t X \r\n";
textBox6.Text = "X \t - \t -Y \r\n";
textBox7.Text = "-Y \t - \t X \r\n";
textBox8.Text = "-X \t - \t -Y \r\n";
textBox9.Text = "-Y \t - \t -X \r\n\n";
textBox10.Text = "-X \t - \t Y \r\n";
textBox11.Text = "Y \t - \t -X \r\n\n";
}

private void button1_Click(object sender, EventArgs e)


{
int xc, yc, r;

xc = Convert.ToInt32(textBox1.Text);
yc = Convert.ToInt32(textBox2.Text);
r = Convert.ToInt32(textBox3.Text);
Circunferencia(r);
Dibujar(xc, yc);
}

private void button2_Click(object sender, EventArgs e)


{
int xc, yc;
xc = Convert.ToInt32(textBox1.Text);
yc = Convert.ToInt32(textBox2.Text);
vector = pictureBox1.CreateGraphics();
int xcentro = pictureBox1.Width / 2;
int ycentro = pictureBox1.Height / 2;
vector.TranslateTransform(xcentro, ycentro);
vector.ScaleTransform(1, -1);
lapiz2 = new Pen(Color.Yellow);
for(int i=1;i<z;i++)
{
vector.DrawLine(lapiz2, xc, yc, (cx[i] + xc), (cy[i] + yc));
}
}

private void button3_Click(object sender, EventArgs e)


{
pictureBox1.Image = null;
vector = pictureBox1.CreateGraphics();
int xcentro = pictureBox1.Width / 2;
int ycentro = pictureBox1.Height / 2;
Pen lapiz = new Pen(Color.Black, 2);
vector.TranslateTransform(xcentro, ycentro);
vector.ScaleTransform(1, -1);
vector.DrawLine(lapiz, xcentro * -1, 0, xcentro * 2, 0);
vector.DrawLine(lapiz, 0, ycentro, 0, ycentro * -1);

for (int i = -xcentro; i < xcentro; i += 10)


{
vector.DrawLine(lapiz, 5, i, -5, i);//division de las y
vector.DrawLine(lapiz, i, 5, i, -5);//division de las x

}
textBox1.Text = "0";
textBox2.Text = "0";
textBox3.Text = "0";
textBox4.Text = "Pk\t-\tX\t-\tY \r\n";
textBox5.Text = "Y \t - \t X \r\n";
textBox6.Text = "X \t - \t -Y \r\n";
textBox7.Text = "-Y \t - \t X \r\n";
textBox8.Text = "-X \t - \t -Y \r\n";
textBox9.Text = "-Y \t - \t -X \r\n\n";
textBox10.Text = "-X \t - \t Y \r\n";
textBox11.Text = "Y \t - \t -X \r\n\n";
z = 1;
}

private void pictureBox1_Paint(object sender, PaintEventArgs e)


{
int xcentro = pictureBox1.Width / 2;
int ycentro = pictureBox1.Height / 2;
Pen lapiz = new Pen(Color.Black, 2);
e.Graphics.TranslateTransform(xcentro, ycentro);//convierte las
coordenadas a la forma de la grafica
e.Graphics.ScaleTransform(1, -1);//se convierten a coordenadas normales

e.Graphics.DrawLine(lapiz, xcentro * -1, 0, xcentro * 2, 0);


e.Graphics.DrawLine(lapiz, 0, ycentro, 0, ycentro * -1);
using (Font myFont = new Font("Arial", 14))

for (int i = -xcentro; i < xcentro; i += 10)


{
e.Graphics.DrawLine(lapiz, 5, i, -5, i);//division de las y
e.Graphics.DrawLine(lapiz, i, 5, i, -5);//division de las x
}

int j = -300, k = 250, m = 18;


for (int l = 50; l < 960; l += 50)
{

using (Font font = new Font("Times New Roman", 10, FontStyle.Bold,


GraphicsUnit.Pixel))
{
Point point1 = new Point(l - 10, ycentro + 10);
if (j != 0)
{
TextRenderer.DrawText(e.Graphics, Convert.ToString(j), font,
point1, Color.Blue);
}
Point point2 = new Point(xcentro + 10, m);
if (k != 0)
{
TextRenderer.DrawText(e.Graphics, Convert.ToString(k), font,
point2, Color.Blue);
}
}
j += 50;
k -= 50;
m += 50;
}
}

void Circunferencia(int radio)


{
int r, pk, corX, corY, i;
r = radio;
pk = 1 - r;
corX = 0;
corY = r;
int xc, yc;
xc = Convert.ToInt32(textBox1.Text);
yc = Convert.ToInt32(textBox2.Text);

for (i = 1; i <= corY; i++)// x, y


{
textBox4.Text += pk + "\t-\t";
if (pk < 0)
{
corX += 1;
pk = pk + (2 * corX) + 1;

}
else if (pk >= 0)
{
corX += 1;
corY -= 1;
pk = pk + (2 * corX) + 1 - (2 * corY);
}
cx[z] = corX;
cy[z] = corY;
textBox4.Text += "" + (cx[z]+xc) + "\t-\t" + (cy[z]+yc) + " \r\n";
z++;
}
int j = i;
for(i=i-1; i>=1;i--)//y, x
{
cx[z] = cy[i];
cy[z] = cx[i];
textBox5.Text += "" + (cy[z] + yc) + "\t-\t" + (cx[z] + xc) + " \r\n";
z++;
}
for (int l = 1; l < j; l++)//-y, x
{
cx[z] = cy[l];
cy[z] = -cx[l];
textBox7.Text += "" + (cy[z] + yc) + "\t-\t" + (cx[z] + xc) + " \r\n";
z++;
}
for (int l = j; l >= 1; l--)//x, -y
{
cx[z] = cx[l];
cy[z] = -cy[l];
textBox6.Text += "" + (cx[z] + xc) + "\t-\t" + (cy[z] + yc) + " \r\n";
z++;
}
for (int l = 1; l < j; l++)//-x, -y
{
cx[z] = -cx[l];
cy[z] = -cy[l];
textBox8.Text += "" + (cx[z] + xc) + "\t-\t" + (cy[z] + yc) + " \r\n";
z++;
}
for (int l = j; l >= 1; l--)//-y, -x
{
cx[z] = -cy[l];
cy[z] = -cx[l];
textBox9.Text += "" + (cy[z] + yc) + "\t-\t" + (cx[z] + xc) + " \r\n";
z++;
}

for (int l = 1; l < j; l++)//y, -x


{
cx[z] = -cy[l];
cy[z] = cx[l];
textBox11.Text += "" + (cy[z] + yc) + "\t-\t" + (cx[z] + xc) + " \r\n";
z++;
}
for (int l = j; l >= 1; l--)//-x, y
{
cx[z] = -cx[l];
cy[z] = cy[l];
textBox10.Text += "" + (cx[z] + xc) + "\t-\t" + (cy[z] + yc) + " \r\n";
z++;
}
}

void Dibujar(int x, int y)


{
int xc, yc;
xc = Convert.ToInt32(textBox1.Text);
yc = Convert.ToInt32(textBox2.Text);
vector = pictureBox1.CreateGraphics();
int xcentro = pictureBox1.Width / 2;
int ycentro = pictureBox1.Height / 2;
Pen lapiz = new Pen(Color.Red, 2);
vector.TranslateTransform(xcentro, ycentro);
vector.ScaleTransform(1, -1);
for (int i = 1; i < z; i++)
{
vector.DrawRectangle(lapiz, (cx[i]+xc), (cy[i]+yc), 1, 1);
}
}
}
}

You might also like