ConsoleGraphics 0.1.3
See the version list below for details.
dotnet add package ConsoleGraphics --version 0.1.3
NuGet\Install-Package ConsoleGraphics -Version 0.1.3
<PackageReference Include="ConsoleGraphics" Version="0.1.3" />
paket add ConsoleGraphics --version 0.1.3
#r "nuget: ConsoleGraphics, 0.1.3"
// Install ConsoleGraphics as a Cake Addin #addin nuget:?package=ConsoleGraphics&version=0.1.3 // Install ConsoleGraphics as a Cake Tool #tool nuget:?package=ConsoleGraphics&version=0.1.3
ConsoleGraphics
A small library for drawing simple geometric shapes in console. The library was created for fun, but then it turned into a small project for rendering simple graphics.
NuGet install:
Install-Package ConsoleGraphics -Version 0.1.1
Usage:
Start
using ConsoleGraphics.Graphics2D.Bases;
First of all, let's create a plane for drawing.
Plane2D Plane = new Plane2D(GraphicsType.ColoredPoints);
Here, in the constructor, there is a GraphicsType value. GraphicsType is the type of graphics that will be used to draw the dots. There are 2 types:
GraphicsType.ColoredSymbols
GraphicsType.ColoredPoints
An example of each can be seen in the pictures:
GraphicsType.ColoredSymbols:
GraphicsType.ColoredPoints:
First Object:
Okay, once we've chosen a graphic type and we've already created a plane instance, we can create our first object: Point.
Point A = new Point(X, Y, Parent, Color, Name, DrawChar);
Where X is the X-Coordinate that this point will have.
and Y is the Y-Coordinate that this point will have.
Parent is the Plane2D where the figure will be drawn.
Color is the ConsoleColor with which the Point will be drawn.
Name is name of the point, can be anything, just for convenience. Used in the ToString() method of GeometricalObject.
DrawChar is the char that the Point will be Draw drawn with.
Okey, now we can do this.
Point A = new Point(0, 0, Plane, ConsoleColor.Magenta, "A", 'O');
But if we run the program, then we will not see the point in the console, all because we need to add this point to Plane2D.
Plane.Add(A);
And, tadam, we now have a point drawn in the console!
Oh, and don't forget to put Console.ReadLine();
at the end of the main method, otherwise it will terminate and not even have time to appear.
Lines, Shapes, Circles...
Well, what about more complex shapes? Such as line segments, rectangles and circles?
The answer lies here:
By adding 2 points between each other, we can get a line segment.
Plane2D Plane = new Plane2D(GraphicsType.ColoredPoints);
Point A = new Point(10, 5, Plane, ConsoleColor.Magenta, "A", '*');
Point B = new Point(15, 8, Plane, ConsoleColor.Magenta, "B", '*');
LineSegment AB = A + B;
Plane.Add(AB);
Result:
We can also create a line segment using the constructor.
By adding a point to a line segment, you can already get a shape.
Plane2D Plane = new Plane2D(GraphicsType.ColoredPoints);
Point A = new Point(10, 5, Plane, ConsoleColor.Magenta, "A");
Point B = new Point(30, 15, Plane, ConsoleColor.Magenta, "B");
Point C = new Point(10, 15, Plane, ConsoleColor.Magenta, "C");
LineSegment AB = A + B;
Shape ABC = AB + C;
Plane.Add(ABC);
Result:
You can also create new shapes by adding a line segment to a line segment.
Plane2D Plane = new Plane2D(GraphicsType.ColoredPoints);
Point A = new Point(10, 5, Plane, ConsoleColor.Magenta, "A");
Point B = new Point(30, 5, Plane, ConsoleColor.Magenta, "B");
Point C = new Point(30, 15, Plane, ConsoleColor.Magenta, "C");
Point D = new Point(10, 15, Plane, ConsoleColor.Magenta, "D");
LineSegment AB = A + B;
LineSegment CD = C + D;
Shape ABCD = AB + CD;
Plane.Add(ABCD);
Result:
Points or lines can be added to shapes to create a new shape. The figure can also be created through the constructor, as it is more convenient for you.
You can also create a circle, though only through the constructor.
Plane2D Plane = new Plane2D(GraphicsType.ColoredPoints);
Circle C = new Circle(10, 5, 3, 6, Plane, ConsoleColor.Magenta);
Plane.Add(C);
Result:
At the end:
There are many possibilities with this library, but so far many of my ideas have not yet been implemented here.
I will update this library as soon as possible.
Thank you for your attention.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.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.