44 lines
1.1 KiB
Text
44 lines
1.1 KiB
Text
#include <time.h>
|
|
#include <cstdlib>
|
|
#include "CImg.h"
|
|
#include "SL_Generated.h"
|
|
|
|
using namespace std;
|
|
using namespace cimg_library;
|
|
|
|
int main(int argc, char ** argv)
|
|
{
|
|
int threads = 0;
|
|
int worldSize = 300; if(argc > 1) worldSize = atoi(argv[1]);
|
|
int seed = time(NULL); if(argc > 2) seed = atoi(argv[2]);
|
|
int scale = 2; if(argc > 3) scale = atoi(argv[3]);
|
|
|
|
sl_init(threads);
|
|
|
|
_sl_RET_VAL current;
|
|
_sl_RET_VAL result;
|
|
|
|
const unsigned char black[] = {0};
|
|
|
|
CImg<unsigned char> visu(worldSize * scale, worldSize * scale, 1, 1, 0);
|
|
CImgDisplay draw_disp(visu);
|
|
cout << "Brownian Tree in SequenceL" << endl << "Threads: " << threads << endl;
|
|
draw_disp.set_title("Brownian Tree in SequenceL: %d Threads", threads);
|
|
|
|
visu.fill(255);
|
|
|
|
sl_initialWorld(worldSize, seed, threads, current);
|
|
|
|
while(!draw_disp.is_closed())
|
|
{
|
|
visu.draw_circle((current.Point.val().Y - 1) * scale, (current.Point.val().X - 1) * scale, scale/2, black, 1);
|
|
visu.display(draw_disp);
|
|
sl_step(current.Rand.val(), current.World, threads, result);
|
|
current = result;
|
|
draw_disp.wait(1);
|
|
}
|
|
|
|
sl_done();
|
|
|
|
return 0;
|
|
}
|