It works, ofc.
This commit is contained in:
parent
88872b4e6a
commit
facbfc3593
2 changed files with 61 additions and 8 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="HTLLeonding.Utility.Turtle" Version="1.1.0" />
|
<PackageReference Include="HTLLeonding.Utility.Turtle" Version="1.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using LeoTurtle;
|
using System.Drawing;
|
||||||
|
using LeoTurtle;
|
||||||
|
|
||||||
namespace SimpleDrawings;
|
namespace SimpleDrawings;
|
||||||
|
|
||||||
|
|
@ -25,7 +26,19 @@ public static class TurtlePath
|
||||||
const double ShortDistance = 4.24D;
|
const double ShortDistance = 4.24D;
|
||||||
const double LongDistance = 8.49D;
|
const double LongDistance = 8.49D;
|
||||||
|
|
||||||
// TODO
|
turtle.Teleport(5, 20);
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
DrawLine(turtle, Distance, 90);
|
||||||
|
}
|
||||||
|
turtle.Turn(45);
|
||||||
|
DrawLine(turtle, LongDistance, -90);
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
DrawLine(turtle, ShortDistance, -90);
|
||||||
|
}
|
||||||
|
DrawLine(turtle, LongDistance, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -34,7 +47,9 @@ public static class TurtlePath
|
||||||
/// <param name="turtle">The <see cref="Turtle"/> instance to use</param>
|
/// <param name="turtle">The <see cref="Turtle"/> instance to use</param>
|
||||||
private static void Shapes(Turtle turtle)
|
private static void Shapes(Turtle turtle)
|
||||||
{
|
{
|
||||||
// TODO
|
DrawOctagon(turtle, 5, 5);
|
||||||
|
DrawRhombus(turtle, 20, 5);
|
||||||
|
DrawTriangle(turtle, 35, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -45,7 +60,12 @@ public static class TurtlePath
|
||||||
/// <param name="startY">Initial turtle y position when starting to draw</param>
|
/// <param name="startY">Initial turtle y position when starting to draw</param>
|
||||||
private static void DrawOctagon(Turtle turtle, int startX, int startY)
|
private static void DrawOctagon(Turtle turtle, int startX, int startY)
|
||||||
{
|
{
|
||||||
// TODO
|
const double Distance = 4.0D;
|
||||||
|
turtle.Teleport(startX, startY);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
DrawLine(turtle, Distance, 45);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -56,7 +76,16 @@ public static class TurtlePath
|
||||||
/// <param name="startY">Initial turtle y position when starting to draw</param>
|
/// <param name="startY">Initial turtle y position when starting to draw</param>
|
||||||
private static void DrawRhombus(Turtle turtle, int startX, int startY)
|
private static void DrawRhombus(Turtle turtle, int startX, int startY)
|
||||||
{
|
{
|
||||||
// TODO
|
const double Distance = 8.0D;
|
||||||
|
const double Angle1 = 82;
|
||||||
|
const double Angle2 = (360 - (Angle1 * 2)) / 2;
|
||||||
|
|
||||||
|
turtle.Teleport(startX + Distance / 2, startY - Distance / 2);
|
||||||
|
turtle.Turn(-Angle1 / 2);
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
DrawLine(turtle, Distance, i % 2 == 0 ? Angle1 : Angle2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -67,7 +96,11 @@ public static class TurtlePath
|
||||||
/// <param name="startY">Initial turtle y position when starting to draw</param>
|
/// <param name="startY">Initial turtle y position when starting to draw</param>
|
||||||
private static void DrawTriangle(Turtle turtle, int startX, int startY)
|
private static void DrawTriangle(Turtle turtle, int startX, int startY)
|
||||||
{
|
{
|
||||||
// TODO
|
const double Offset = 1.5D;
|
||||||
|
const double ShortSide = 6.0D;
|
||||||
|
const double LongSide = 8.0D;
|
||||||
|
DrawTriangle(turtle, startX, startY, LongSide, ShortSide);
|
||||||
|
DrawTriangle(turtle, startX - Offset, startY - Offset*2, LongSide + Offset*(LongSide/2), ShortSide + Offset*(ShortSide/2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -81,7 +114,16 @@ public static class TurtlePath
|
||||||
/// <param name="shortSide">Length of sides a & b</param>
|
/// <param name="shortSide">Length of sides a & b</param>
|
||||||
private static void DrawTriangle(Turtle turtle, double startX, double startY, double longSide, double shortSide)
|
private static void DrawTriangle(Turtle turtle, double startX, double startY, double longSide, double shortSide)
|
||||||
{
|
{
|
||||||
// TODO
|
turtle.Teleport(startX, startY);
|
||||||
|
|
||||||
|
double angle = ConvertToDegrees(Math.Asin(shortSide / longSide)); // Corrected to arcsin
|
||||||
|
DrawLine(turtle, longSide, 180 - angle); // Long side
|
||||||
|
DrawLine(turtle, shortSide, 0);
|
||||||
|
|
||||||
|
turtle.Teleport(startX, startY);
|
||||||
|
turtle.Turn(angle);
|
||||||
|
DrawLine(turtle, shortSide, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -93,4 +135,15 @@ public static class TurtlePath
|
||||||
{
|
{
|
||||||
return angleDegrees * Math.PI / 180;
|
return angleDegrees * Math.PI / 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static double ConvertToDegrees(double angleRadians)
|
||||||
|
{
|
||||||
|
return angleRadians / Math.PI * 180;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DrawLine(Turtle turtle, double distance, double rotation)
|
||||||
|
{
|
||||||
|
turtle.MoveForward(distance);
|
||||||
|
turtle.Turn(rotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue