24 lines
477 B
C++
24 lines
477 B
C++
|
|
#include "customscene.h"
|
||
|
|
#include "rustlib.h"
|
||
|
|
|
||
|
|
#include <QPainter>
|
||
|
|
|
||
|
|
CustomScene::CustomScene(QWidget *parent)
|
||
|
|
: QWidget{parent}
|
||
|
|
{}
|
||
|
|
|
||
|
|
void CustomScene::paintEvent(QPaintEvent *event)
|
||
|
|
{
|
||
|
|
QPainter painter(this);
|
||
|
|
|
||
|
|
painter.translate(width() / 2, height() / 2);
|
||
|
|
|
||
|
|
for (int i = 0; i < 20; i++) {
|
||
|
|
int segmentLength = fFibonacci(i);
|
||
|
|
painter.drawLine(0, 0, segmentLength, 0);
|
||
|
|
|
||
|
|
painter.translate(segmentLength, 0);
|
||
|
|
painter.rotate(90);
|
||
|
|
}
|
||
|
|
}
|