Nakov.TurtleGraphics
2.0.0.1
See the version list below for details.
dotnet add package Nakov.TurtleGraphics --version 2.0.0.1
NuGet\Install-Package Nakov.TurtleGraphics -Version 2.0.0.1
<PackageReference Include="Nakov.TurtleGraphics" Version="2.0.0.1" />
paket add Nakov.TurtleGraphics --version 2.0.0.1
#r "nuget: Nakov.TurtleGraphics, 2.0.0.1"
// Install Nakov.TurtleGraphics as a Cake Addin #addin nuget:?package=Nakov.TurtleGraphics&version=2.0.0.1 // Install Nakov.TurtleGraphics as a Cake Tool #tool nuget:?package=Nakov.TurtleGraphics&version=2.0.0.1
Getting Started - Creating a Windows Forms Turtle Graphics App
- Create a new empty Windows Form application with Visual Studio.
- Install the NuGet package "Nakov.TurtleGraphics" from the Package Management Console in Visual Studio:
Install-Package Nakov.TurtleGraphics
- Put a button [Draw]. Handle the
Click
event and add this code:
// Assign a delay to visualize the drawing process
Turtle.Delay = 200;
// Draw a equilateral triangle
Turtle.Rotate(30);
Turtle.Forward(200);
Turtle.Rotate(120);
Turtle.Forward(200);
Turtle.Rotate(120);
Turtle.Forward(200);
// Draw a line in the triangle
Turtle.Rotate(-30);
Turtle.PenUp();
Turtle.Backward(50);
Turtle.PenDown();
Turtle.Backward(100);
Turtle.PenUp();
Turtle.Forward(150);
Turtle.PenDown();
Turtle.Rotate(30);
- Enjoy the application:
See the full source code here: https://github.com/nakov/TurtleGraphics.NET/tree/master/Turtle-Graphics-Example.
TurtleGraphics.NET - Developer's Reference
The interface is intentionally simplified through a single static class (I know this is not a good practice in OOP), to enable kids start playing with the turtle with just few clicks, without knowing anything about "classes" and "objects". The class Turtle
supports all major turtle graphics primitives in Windows Forms C# / .NET GUI applications:
Init()
- initializes the turtle graphics system. Callers can specify the target Windows Forms control to hold the drawing surface (e.g. a Panel). If not specified, the currently active form is used as drawing surface. If not called, it will be called on demand with the first turtle move / draw command. Initially the turtle location is {0, 0} (the screen center) and the direction (angle) is 0 degrees (up).Dispose()
/Reset()
- destroys the turtle graphics system and deallocates all resources, associated with it.Forward(distance)
- moves the turtle forward in the current direction by the specified distance. If the pen is down, the turtle draws a line from the current to the new position, otherwise it just moves without leaving a track.Backward(distance)
- moves the turtle in backward direction and draws a line if the pen is down.MoveTo(x, y)
- moves the turtle to the specified position and draws a line if the pen is down.Rotate(angle)
- rotates the turtle relatively to the current direction. The rotation angle is given in degrees (e.g. 45, -30, 315, ...).RotateTo(angle)
- rotates the turtle to the specified angle in degrees (e.g. 0, 45, 180, 315, ...).PenUp()
- moves the pen up (makes further moves invisible). Further calls toForward(distance)
/Backward(distance)
/MoveTo(x, y)
will move the turtle without drawing a line.PenDown()
- moves the pen down (makes further moves visible). Further calls toForward(distance)
/Backward(distance)
/MoveTo(x, y)
will draw a line from the current to the new position.X
- gets / sets the current turtle horizontal position. The initial turtle position is the screen center {0, 0}. Increasing X will move the turtle right.Y
- gets / sets the current turtle vertical position. The initial turtle position is the screen center {0, 0}. Increasing Y will move the turtle up.Angle
- gets / sets the current turtle direction (angle in degrees). The value of 0 means up, 90 means right, 180 means down and 270 means left. TheAngle
is always kept in the range [0...360). Initially the angle is 0.PenColor
- gets / sets the color of the pen. The default pen color is "blue".PenSize
- gets / sets the size of the pen (in pixels). The default pen size is 7.PenVisible
- gets / sets the visibility of the pen. The default pen size is true. True means the pen is down (draws a line when the turtle moves). False means the pen is up (no line is drawn when the turtle moves).ShowTurtle
- gets / sets whether the turtle is visible. By default it is visible.Delay
- gets / sets the turtle delay in milliseconds after moving / rotating. By default the delay is 0 (no delay). Setting the delay to 100-300 will simulate a pleasant "animation effect".Delay
is preserved afterReset()
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net5.0-windows7.0 is compatible. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net5.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
This release supports .NET Core and .NET Framework.