rendering astroid
This commit is contained in:
parent
93af42b93d
commit
4f847aa671
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
QtCurvesCpp.pro.user
|
||||
QtCurvesCpp.pro.user.9311c87
|
||||
QtCurvesCpp.pro.user
|
||||
QtCurvesCpp.pro.user
|
||||
|
@ -10,6 +10,11 @@ RenderArea::RenderArea(QWidget *parent) :
|
||||
|
||||
}
|
||||
|
||||
QPointF RenderArea::ComputeAstroid(float t){
|
||||
double cos_t{cos(t)},sin_t{sin(t)},x{2*cos_t*cos_t*cos_t},y{2*sin_t*sin_t*sin_t};
|
||||
return QPointF{x,y};
|
||||
}
|
||||
|
||||
QSize RenderArea::minimumSizeHint() const
|
||||
{
|
||||
return QSize(100,100);
|
||||
@ -48,5 +53,17 @@ void RenderArea::paintEvent(QPaintEvent* event)
|
||||
painter.setPen(mShapeColour);
|
||||
|
||||
painter.drawRect(this->rect());
|
||||
painter.drawLine(this->rect().topLeft(),this->rect().bottomRight());
|
||||
|
||||
QPoint center{this->rect().center()};
|
||||
int stepCount{1024};
|
||||
double scale{40},intervalLenght{2 * M_PI},step{intervalLenght / stepCount};
|
||||
for(float t = 0; t < intervalLenght; t += step){
|
||||
QPointF point = ComputeAstroid(t);
|
||||
|
||||
QPoint pixel;
|
||||
pixel.setX(point.x() * scale + center.x());
|
||||
pixel.setY(point.y() * scale + center.y());
|
||||
|
||||
painter.drawPoint(pixel);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class RenderArea : public QWidget
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QPointF ComputeAstroid(float t);
|
||||
QColor mBackgroundColour;
|
||||
QColor mShapeColour;
|
||||
ShapesType mShape;
|
||||
|
Loading…
Reference in New Issue
Block a user