Skip to content

Instantly share code, notes, and snippets.

@firestorm713
Created September 17, 2014 04:09
Show Gist options
  • Select an option

  • Save firestorm713/a213f56cd4dde8ec3059 to your computer and use it in GitHub Desktop.

Select an option

Save firestorm713/a213f56cd4dde8ec3059 to your computer and use it in GitHub Desktop.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "basetexture.h"
#include <iostream>
#include<string>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
initTextures();
baseTex = new QImage(512, 512, QImage::Format_RGBA8888);
Octaves.push_back(new QImage(512, 512, QImage::Format_RGBA8888));
finalTex = new QImage(512, 512, QImage::Format_RGBA8888);
baseTex->fill(Qt::GlobalColor::red);
Octaves[0]->fill(Qt::GlobalColor::red);
finalTex->fill(Qt::GlobalColor::red);
for(int i = 0; i < 512; i++)
for (int j = 0; j < 512; j++)
finalTex->setPixel(i,i,qRgb(0,0,0));
QWidget* widget = this->findChild<QWidget*>("centralWidget");
displayFinal = widget->findChild<QGraphicsView *>("TextureDisplay");
finalTexDisp = new QPixmap(512, 512);
finalTexDisp->convertFromImage(*finalTex, 0);
texScene = new QGraphicsScene();
// displayFinal = new QGraphicsView();
texScene->addPixmap(*finalTexDisp);
displayFinal->setScene(texScene);
//displayFinal->setSceneRect(0,0,512,512);
displayFinal->show();
}
void MainWindow::initTextures()
{
// initialize base and final textures
}
void MainWindow::addTextures()
{
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_OctavesSlider_sliderMoved(int position)
{
if(position <1)
{
position = 1;
numOctaves = 1;
}
// if position is less than octaves.size
// pop octaves off list until octaves.size is equal to position
// re-add up octaves to gain new texture
// if position is greater than octaves
// push new octaves onto list until octaves.size is equal to position
// recalculate texture based on new octaves
}
void MainWindow::on_Persistence_Slider_sliderMoved(int position)
{
}
void MainWindow::on_SeedBox_textEdited(const QString &arg1)
{
// Qstring::toInt the seed
// recalculate the texture based on the new seed
}
void MainWindow::on_BaseTexButton_clicked()
{
BaseTexture *bt = new BaseTexture();
bt->show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment