kleinere Änderungen um ANSI Consolen Demo auszuprobieren

Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
Johannes Theiner 2018-08-28 09:23:14 +02:00
parent 32fb4614f0
commit d7519daf38
3 changed files with 13 additions and 12 deletions

View File

@ -1,6 +1,6 @@
#include <iostream>
#include <cmath>
#include "AnsiConsole.h"
#include "../../helpers/AnsiConsole.h"
/*
see

View File

@ -6,7 +6,7 @@ struct Position {
int x;
int y;
Position(int x_ = 0, int y_ = 0) {
explicit Position(int x_ = 0, int y_ = 0) {
x = x_;
y = y_;
}
@ -16,7 +16,7 @@ class Point {
protected:
Position _position;
public:
Point(int x = 0, int y = 0);
explicit Point(int x = 0, int y = 0);
void draw();
};
@ -34,7 +34,7 @@ protected:
Position _position;
int _radius;
public:
Circle(int x = 0, int y = 0, int radius = 0);
explicit Circle(int x = 0, int y = 0, int radius = 0);
void draw();
};
@ -55,10 +55,10 @@ void Circle::draw() {
double x_relative = double(i) - double(x_start);
double h = sqrt(x_relative * (x_stop - x_start - x_relative));
ansiConsole.printText(_position.x + int(x_relative) - _radius / 2,
_position.y + h, "#",
static_cast<int>(_position.y + h), "#",
Colors::GREEN);
ansiConsole.printText(_position.x + int(x_relative) - _radius / 2,
_position.y - h, "#",
static_cast<int>(_position.y - h), "#",
Colors::GREEN);
}
@ -71,7 +71,7 @@ protected:
int height;
public:
Rectangle(int x = 0, int y = 0, int width = 0, int height = 0);
explicit Rectangle(int x = 0, int y = 0, int width = 0, int height = 0);
void draw();
};
@ -103,20 +103,20 @@ int main(int argc, char **argv) {
// x and y are more like column and row
ansiConsole.printText(5, 5, "Hello, World!");
Point *p = new Point(10, 10);
auto *p = new Point(10, 10);
p->draw();
Point *p2 = new Point(2, 10);
auto *p2 = new Point(2, 10);
p2->draw();
Circle *c = new Circle(30, 15, 10);
auto *c = new Circle(30, 15, 10);
c->draw();
Point *p3 = new Point(30, 15);
auto *p3 = new Point(30, 15);
p3->draw();
Rectangle *r = new Rectangle(20, 20, 20, 20);
auto *r = new Rectangle(20, 20, 20, 20);
r->draw();

View File

@ -19,6 +19,7 @@ add_executable(04_UDEF_Testat 04_UDEF/Testat/Testat.cpp)
add_executable(05_OO_MP 05_OO/MP/shapes_main.cpp helpers/AnsiConsole.cpp)
add_executable(05_OO_Testat 05_OO/Testat/shapes_main.cpp helpers/AnsiConsole.cpp)
add_executable(05_OO_Demo 05_OO/MP/AnsiConsoleDemo.cpp helpers/AnsiConsole.cpp)
add_executable(06_POLY_MP 06_POLY/MP/main_mp5_POLY.cpp)
#add_executable(06_POLY_Testat 06_POLY/Testat/main_mp5_POLY.cpp)