Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void drawTriangle(PaintEventArgs e, int x, int y, int distance)
- {
- float angle = 0;
- SolidBrush brs = new SolidBrush(Color.Green);
- PointF[] p = new PointF[3];
- p[0].X = x;
- p[0].Y = y;
- p[1].Y = (float)( x + distance * Math.Cos(angle + Math.PI / 3));
- p[1].X = (float)( y + distance * Math.Sin(angle + Math.PI / 3));
- p[2].Y = (float)( x + distance * Math.Cos(angle - Math.PI / 3));
- p[2].X = (float)( y + distance * Math.Sin(angle - Math.PI / 3));
- e.Graphics.FillPolygon(brs, p);
- }
- p[0].X = x;
- p[0].Y = y;
- p[1].X = (float)( x + distance * Math.Cos(angle));
- p[1].Y = (float)( y + distance * Math.Sin(angle));
- p[2].X = (float)( x + distance * Math.Cos(angle + Math.PI / 3));
- p[2].Y = (float)( y + distance * Math.Sin(angle + Math.PI / 3));
- var size = int.Parse(Console.ReadLine());
- for (int i = 1; i <= size; i++)
- {
- int leftPadding = 1 + (((2 * size - 1) - (2 * i + 1)) / 2);
- StringBuilder build = new StringBuilder();
- build.Append(new string(Enumerable.Repeat(' ', leftPadding > 0 ? leftPadding: 0).ToArray()));
- for (int j = 1; j <= i; j++)
- {
- build.Append("* ");
- }
- Console.WriteLine(build.ToString());
- }
Add Comment
Please, Sign In to add comment