Всі лабараторні роботи з ООП за 1-й курс (ЖДТУ)
15

{

}

#include "Rect.h"

 

Rectangle::Rectangle( double x, double y, double _w,double _h)

{

A=Point(x, y);

w = _w;

h = _h;

 

rect.setSize(Vector2f(w, h));

rect.setFillColor(Color::Color(255, 0, 0));

rect.setOutlineColor(Color::Blue);

r = 0;

select = true;

}

 

void Rectangle::Move()

{

A.Move();

}

 

void Rectangle::Draw(RenderWindow & window)

{

rect.setPosition(A.getX(), A.getY());

if(select)

{

rect.setOutlineThickness(-2);

}

else

rect.setOutlineThickness(0);

window.draw(rect);

}

 

void Rectangle::Rotate()

{

if (Keyboard::isKeyPressed(Keyboard::W))rect.setRotation(r-=0.1);

if (Keyboard::isKeyPressed(Keyboard::S))rect.setRotation(r+=0.1);

}

 

void Rectangle::Scale()

{

if (Keyboard::isKeyPressed(Keyboard::PageUp))rect.setSize(Vector2f(w += 0.1, h += 0.1));

if (Keyboard::isKeyPressed(Keyboard::PageDown))rect.setSize(Vector2f(w -= 0.1, h -= 0.1));

}

 

void Rectangle::SetColor()

{

int r, g, b;

if(Keyboard::isKeyPressed(Keyboard::C))

{

cout << "enter RGB (0-255)\n";

cin >> r >> g >> b;

rect.setFillColor(Color::Color(r, g, b));

rect.setOutlineColor(Color::Color((255- r)*2, (255 - g) * 2, (255 - b) * 2));

}

}

#include "Str.h"

#include <cmath>

 

 

Str::Str(Point& a,double l)