53 lines
915 B
C++
53 lines
915 B
C++
#include "renderarea.h"
|
|
#include <QPainter>
|
|
|
|
RenderArea::RenderArea(QWidget *parent) :
|
|
QWidget{parent},
|
|
mBackgroundColour{36,35,35},
|
|
mShapeColour{251,250,250},
|
|
mShape{Astroid}
|
|
{
|
|
|
|
}
|
|
|
|
QSize RenderArea::minimumSizeHint() const
|
|
{
|
|
return QSize(100,100);
|
|
}
|
|
|
|
QSize RenderArea::sizeHint() const
|
|
{
|
|
return QSize(400,200);
|
|
}
|
|
|
|
void RenderArea::paintEvent(QPaintEvent* event)
|
|
{
|
|
QPainter painter{this};
|
|
painter.setRenderHint(QPainter::Antialiasing,true);
|
|
|
|
switch (mShape) {
|
|
case Astroid:
|
|
mBackgroundColour = Qt::red;
|
|
break;
|
|
case Cycloid:
|
|
mBackgroundColour = Qt::green;
|
|
|
|
break;
|
|
case HuygensCycloid:
|
|
mBackgroundColour = Qt::blue;
|
|
|
|
break;
|
|
case HypoCycloid:
|
|
mBackgroundColour = Qt::yellow;
|
|
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
painter.setBrush(mBackgroundColour);
|
|
painter.setPen(mShapeColour);
|
|
|
|
painter.drawRect(this->rect());
|
|
painter.drawLine(this->rect().topLeft(),this->rect().bottomRight());
|
|
}
|