ConsoleGraphics 0.1.4

dotnet add package ConsoleGraphics --version 0.1.4
                    
NuGet\Install-Package ConsoleGraphics -Version 0.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ConsoleGraphics" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ConsoleGraphics" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="ConsoleGraphics" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ConsoleGraphics --version 0.1.4
                    
#r "nuget: ConsoleGraphics, 0.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ConsoleGraphics@0.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ConsoleGraphics&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=ConsoleGraphics&version=0.1.4
                    
Install as a Cake Tool

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.4

Usage:

Start

using ConsoleGraphics.Graphics2D.Bases;

First of all, let's create a scene for drawing.

Scene2D Scene = new Scene2D(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:

image

GraphicsType.ColoredPoints:

image

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, 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.

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, 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 Scene2D.

Scene.Add(A);

And, tadam, we now have a point drawn in the console!

image

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.

Scene2D Scene = new Scene2D(GraphicsType.ColoredPoints);
Point A = new Point(10, 5, ConsoleColor.Magenta, "A", '*');
Point B = new Point(15, 8, ConsoleColor.Magenta, "B", '*');
LineSegment AB = A + B;
Scene.Add(AB);

Result:

image

We can also create a line segment using the constructor.

By adding a point to a line segment, you can already get a shape.

Scene2D Scene = new Scene2D(GraphicsType.ColoredPoints);
Point A = new Point(10, 5, ConsoleColor.Magenta, "A");
Point B = new Point(30, 15, ConsoleColor.Magenta, "B");
Point C = new Point(10, 15, ConsoleColor.Magenta, "C");
LineSegment AB = A + B;
Shape ABC = AB + C;
Scene.Add(ABC);

Result:

image

You can also create new shapes by adding a line segment to a line segment.

Scene2D Scene = new Scene2D(GraphicsType.ColoredPoints);
Point A = new Point(10, 5, ConsoleColor.Magenta, "A");
Point B = new Point(30, 5, ConsoleColor.Magenta, "B");
Point C = new Point(30, 15, ConsoleColor.Magenta, "C");
Point D = new Point(10, 15, ConsoleColor.Magenta, "D");
LineSegment AB = A + B;
LineSegment CD = C + D;
Shape ABCD = AB + CD;
Scene.Add(ABCD);

Result:

image

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.

Scene2D Plane = new Scene2D(GraphicsType.ColoredPoints);
Circle C = new Circle(10, 5, 3, 6, ConsoleColor.Magenta);
Scene.Add(C);

Result:

image

Additional goodies

You can move any object in scene space using these methods:

GeometricalObject.SetY(double);
GeometricalObject.SetX(double);

With these methods, you can create small animations, but if you want, you can make normal animations:

Example:

Scene2D Scene = new Scene2D(GraphicsType.ColoredSymbols);
Circle C = new Circle(10, 5, 6, 3, ConsoleColor.DarkGreen);
Scene.Add(C);
for (int i = 0; i < 60; i++)
  {
  try
    {
      C.SetY(i);
      Thread.Sleep(500);
    }
    catch
    {
      break;
    }
}
Console.ReadLine();

Result:

Result

In the next update, I will most likely add a convenient animation implementation.

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 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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
0.1.4 881 7/20/2022
0.1.3 531 7/19/2022