Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Draw_tree(double level, double x, double y, double angle1, double angle2, double coefficient)
- {
- angle1 = angle1 * pi / 180;
- angle2 = angle2 * pi / 180;
- double length = (y - y / 3 * 2);
- double x1 = x, y1 = y / 3 * 2, x2 = x, y2 = y / 3 * 2;
- double xLeft, yLeft, xRight, yRight;
- if (level == 0) graph.DrawLine(pen, (int)x, (int)y, (int)x, (int)(y * 2 / 3));
- else
- {
- xLeft = x1 - length * Math.Cos(pi / 2 - angle1) * coefficient;
- yLeft = y1 - length * Math.Sin(pi / 2 - angle1) * coefficient;
- xRight = x2 + length * Math.Cos(pi / 2 - angle2) * coefficient;
- yRight = y2 - length * Math.Sin(pi / 2 - angle2) * coefficient;
- graph.DrawLine(pen, (int)x1, (int)y1, (int)xLeft, (int)yLeft);
- graph.DrawLine(pen, (int)x2, (int)y2, (int)xRight, (int)yRight);
- x1 = xLeft;
- y1 = yLeft;
- x2 = xRight;
- y2 = yRight;
- Draw_tree(level - 1, x1, y1, angle1, angle2, coefficient);
- Draw_tree(level - 1, x2, y2, angle1, angle2, coefficient);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement