kleinere Änderungen um ANSI Consolen Demo auszuprobieren
Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
parent
32fb4614f0
commit
d7519daf38
|
@ -1,6 +1,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "AnsiConsole.h"
|
#include "../../helpers/AnsiConsole.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
see
|
see
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct Position {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
Position(int x_ = 0, int y_ = 0) {
|
explicit Position(int x_ = 0, int y_ = 0) {
|
||||||
x = x_;
|
x = x_;
|
||||||
y = y_;
|
y = y_;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ class Point {
|
||||||
protected:
|
protected:
|
||||||
Position _position;
|
Position _position;
|
||||||
public:
|
public:
|
||||||
Point(int x = 0, int y = 0);
|
explicit Point(int x = 0, int y = 0);
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ protected:
|
||||||
Position _position;
|
Position _position;
|
||||||
int _radius;
|
int _radius;
|
||||||
public:
|
public:
|
||||||
Circle(int x = 0, int y = 0, int radius = 0);
|
explicit Circle(int x = 0, int y = 0, int radius = 0);
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
};
|
};
|
||||||
|
@ -55,10 +55,10 @@ void Circle::draw() {
|
||||||
double x_relative = double(i) - double(x_start);
|
double x_relative = double(i) - double(x_start);
|
||||||
double h = sqrt(x_relative * (x_stop - x_start - x_relative));
|
double h = sqrt(x_relative * (x_stop - x_start - x_relative));
|
||||||
ansiConsole.printText(_position.x + int(x_relative) - _radius / 2,
|
ansiConsole.printText(_position.x + int(x_relative) - _radius / 2,
|
||||||
_position.y + h, "#",
|
static_cast<int>(_position.y + h), "#",
|
||||||
Colors::GREEN);
|
Colors::GREEN);
|
||||||
ansiConsole.printText(_position.x + int(x_relative) - _radius / 2,
|
ansiConsole.printText(_position.x + int(x_relative) - _radius / 2,
|
||||||
_position.y - h, "#",
|
static_cast<int>(_position.y - h), "#",
|
||||||
Colors::GREEN);
|
Colors::GREEN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ protected:
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
public:
|
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();
|
void draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,20 +103,20 @@ int main(int argc, char **argv) {
|
||||||
// x and y are more like column and row
|
// x and y are more like column and row
|
||||||
ansiConsole.printText(5, 5, "Hello, World!");
|
ansiConsole.printText(5, 5, "Hello, World!");
|
||||||
|
|
||||||
Point *p = new Point(10, 10);
|
auto *p = new Point(10, 10);
|
||||||
p->draw();
|
p->draw();
|
||||||
|
|
||||||
Point *p2 = new Point(2, 10);
|
auto *p2 = new Point(2, 10);
|
||||||
p2->draw();
|
p2->draw();
|
||||||
|
|
||||||
|
|
||||||
Circle *c = new Circle(30, 15, 10);
|
auto *c = new Circle(30, 15, 10);
|
||||||
c->draw();
|
c->draw();
|
||||||
|
|
||||||
Point *p3 = new Point(30, 15);
|
auto *p3 = new Point(30, 15);
|
||||||
p3->draw();
|
p3->draw();
|
||||||
|
|
||||||
Rectangle *r = new Rectangle(20, 20, 20, 20);
|
auto *r = new Rectangle(20, 20, 20, 20);
|
||||||
r->draw();
|
r->draw();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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_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_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_MP 06_POLY/MP/main_mp5_POLY.cpp)
|
||||||
#add_executable(06_POLY_Testat 06_POLY/Testat/main_mp5_POLY.cpp)
|
#add_executable(06_POLY_Testat 06_POLY/Testat/main_mp5_POLY.cpp)
|
||||||
|
|
Loading…
Reference in New Issue