6atafrak
New member
- Joined
- Apr 1, 2021
- Messages
- 2
- Programming Experience
- Beginner
Hey guys, I need help this is code for the triangle from photo
But I need code for drawing this square :
C#:
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.Blue, 2);
int n = 3, m = 30;
//1st
int x1 = 100, y1 = 500, side = 500;
int x2 = x1 + side, y2 = y1;
int h = (int)(side * Math.Sqrt(3) / 2);
int x3 = (x1 + x2) / 2, y3 = y1 - h;
g.DrawLine(p, x1, y1, x2, y2);
g.DrawLine(p, x2, y2, x3, y3);
g.DrawLine(p, x3, y3, x1, y1);
//others
for (int i = 1; i <= 80; i++)
{
int x = x1, y = y1;
x1 = (n * x1 + m * x2) / (n + m);
y1 = (n * y1 + m * y2) / (n + m);
x2 = (n * x2 + m * x3) / (n + m);
y2 = (n * y2 + m * y3) / (n + m);
x3 = (n * x3 + m * x) / (n + m);
y3 = (n * y3 + m * y) / (n + m);
g.DrawLine(p, x1, y1, x2, y2);
g.DrawLine(p, x2, y2, x3, y3);
g.DrawLine(p, x3, y3, x1, y1);
}
But I need code for drawing this square :
Attachments
Last edited by a moderator: