Browse Source

cloud shapes added

master
thepra 5 years ago
parent
commit
6ffd2e7ecc
  1. 14
      mainwindow.cpp
  2. 4
      mainwindow.h
  3. 24
      mainwindow.ui
  4. 35
      renderarea.cpp
  5. 7
      renderarea.h

14
mainwindow.cpp

@ -92,6 +92,20 @@ void MainWindow::on_btnStarfish_clicked()
UpdateUi();
}
void MainWindow::on_btnCloud_clicked()
{
this->ui->renderArea->setShape(RenderArea::Cloud1);
this->ui->renderArea->repaint();
UpdateUi();
}
void MainWindow::on_btnInverseCloud_clicked()
{
this->ui->renderArea->setShape(RenderArea::Cloud2);
this->ui->renderArea->repaint();
UpdateUi();
}
void MainWindow::on_intervalInput_valueChanged(double interval)
{
this->ui->renderArea->setInternalLenght(interval);

4
mainwindow.h

@ -47,6 +47,10 @@ class MainWindow : public QMainWindow
void on_btnStarfish_clicked();
void on_btnCloud_clicked();
void on_btnInverseCloud_clicked();
private:
void UpdateUi();
constexpr static QWidget* root = 0;

24
mainwindow.ui

@ -413,6 +413,30 @@ border-color: rgb(255, 255, 255);</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCloud">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Cloud</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnInverseCloud">
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(36, 35, 35);
border-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>Inverse Cloud</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>

35
renderarea.cpp

@ -121,6 +121,25 @@ QPointF RenderArea::ComputeStarfish(double t)
};
}
QPointF RenderArea::ComputeCloud2(double t)
{
return ComputeCloudWithSign(t,1.);
}
QPointF RenderArea::ComputeCloud1(double t)
{
return ComputeCloudWithSign(t,-1.);
}
QPointF RenderArea::ComputeCloudWithSign(double t,double sign)
{
double a{14},b{1};
return QPointF{
(a+b)*cos(t*(b/a)) + sign*b*cos(t*((a+b)/a)),
(a+b)*sin(t*(b/a)) - b*sin(t*((a+b)/a))
};
}
void RenderArea::OnShapeChanged()
{
switch (mShape) {
@ -169,6 +188,16 @@ void RenderArea::OnShapeChanged()
mIntervalLenght=6*M_PI;
mStepCount=256;
break;
case Cloud1:
mScale=10;
mIntervalLenght=28*M_PI;
mStepCount=128;
break;
case Cloud2:
mScale=10;
mIntervalLenght=28*M_PI;
mStepCount=128;
break;
default:
break;
}
@ -204,6 +233,12 @@ QPointF RenderArea::Compute(double t)
case Starfish:
return ComputeStarfish(t);
break;
case Cloud1:
return ComputeCloud1(t);
break;
case Cloud2:
return ComputeCloud2(t);
break;
default:
break;
}

7
renderarea.h

@ -22,7 +22,9 @@ class RenderArea : public QWidget
Circle,
Ellipse,
Fancy,
Starfish
Starfish,
Cloud1,
Cloud2
};
void setBackgroundColor(QColor color) { mBackgroundColour = color; }
@ -62,6 +64,9 @@ class RenderArea : public QWidget
QPointF ComputeEllipse(double t);
QPointF ComputeFancy(double t);
QPointF ComputeStarfish(double t);
QPointF ComputeCloud1(double t);
QPointF ComputeCloud2(double t);
QPointF ComputeCloudWithSign(double t,double sign);
QColor mBackgroundColour;
ShapesType mShape;
QPen mPen;

Loading…
Cancel
Save