hacked colors in, just for fnu
This commit is contained in:
parent
5036b68865
commit
ce9950b0b3
6 changed files with 37 additions and 29 deletions
|
@ -15,7 +15,7 @@ public:
|
||||||
virtual ~Canvas() {};
|
virtual ~Canvas() {};
|
||||||
|
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
virtual void plot(const double* normalizedPosition) = 0;
|
virtual void plot(const double* normalizedPosition, const double* normalizedColor) = 0;
|
||||||
virtual void output_file(const char* filename) const = 0;
|
virtual void output_file(const char* filename) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ public:
|
||||||
Canvas* canvas;
|
Canvas* canvas;
|
||||||
|
|
||||||
Projector(unsigned int inputDimension, unsigned int outputDimension) :
|
Projector(unsigned int inputDimension, unsigned int outputDimension) :
|
||||||
canvas(0), projector(0), projectedPoint(0),
|
canvas(0), projector(0), projectedPoint(0), projectedColor(0),
|
||||||
inputDimension(inputDimension), outputDimension(outputDimension),
|
inputDimension(inputDimension), outputDimension(outputDimension),
|
||||||
ready(true) {
|
ready(true) {
|
||||||
try {
|
try {
|
||||||
|
@ -23,6 +23,7 @@ public:
|
||||||
deallocate();
|
deallocate();
|
||||||
}
|
}
|
||||||
std::fill_n(projectedPoint, outputDimension, 0.0);
|
std::fill_n(projectedPoint, outputDimension, 0.0);
|
||||||
|
std::fill_n(projectedColor, 1, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Projector() {
|
virtual ~Projector() {
|
||||||
|
@ -34,12 +35,12 @@ public:
|
||||||
|
|
||||||
if(ready) {
|
if(ready) {
|
||||||
if(canvas != NULL) {
|
if(canvas != NULL) {
|
||||||
canvas->plot(projectedPoint);
|
canvas->plot(projectedPoint, projectedColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(projector != NULL) {
|
/*if(projector != NULL) {
|
||||||
projector->plot(projectedPoint);
|
projector->plot(projectedPoint, projectedColor);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ protected:
|
||||||
Projector* projector;
|
Projector* projector;
|
||||||
|
|
||||||
double* projectedPoint;
|
double* projectedPoint;
|
||||||
|
double* projectedColor;
|
||||||
|
|
||||||
unsigned int inputDimension;
|
unsigned int inputDimension;
|
||||||
unsigned int outputDimension;
|
unsigned int outputDimension;
|
||||||
|
@ -60,11 +62,14 @@ protected:
|
||||||
private:
|
private:
|
||||||
void allocate() {
|
void allocate() {
|
||||||
projectedPoint = new double[outputDimension];
|
projectedPoint = new double[outputDimension];
|
||||||
|
projectedColor = new double[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate() {
|
void deallocate() {
|
||||||
delete[] projectedPoint;
|
delete[] projectedPoint;
|
||||||
projectedPoint = NULL;
|
projectedPoint = NULL;
|
||||||
|
delete[] projectedColor;
|
||||||
|
projectedColor = NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
batch.sh
2
batch.sh
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
while true; do ./AwesomeAttractor -R -I 100 -W 1024 -H 1024 -v attractors/emptyUnravel3D.stf; done
|
while true; do ./AwesomeAttractor -P /var/www/render2/ -R -I 2000 -W 1024 -H 1024 -v attractors/emptyUnravel3D.stf; done
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <png++/png.hpp>
|
#include <png++/png.hpp>
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ public:
|
||||||
|
|
||||||
//int_array = std::make_shared<vstd::vector<unsigned int>>(width*height*num_colors);
|
//int_array = std::make_shared<vstd::vector<unsigned int>>(width*height*num_colors);
|
||||||
int_array = new unsigned int[width*height*num_colors];
|
int_array = new unsigned int[width*height*num_colors];
|
||||||
|
LogInfo("PNG::PNG(): width: %d, height: %d, colors: %d\n", width, height, num_colors);
|
||||||
|
|
||||||
assert(int_array != nullptr);
|
assert(int_array != nullptr);
|
||||||
|
|
||||||
|
@ -38,7 +40,7 @@ public:
|
||||||
std::fill_n(int_array, width*height*num_colors, 0);
|
std::fill_n(int_array, width*height*num_colors, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void plot(const double* normalizedPosition) {
|
virtual void plot(const double* normalizedPosition, const double* normalizedColor) {
|
||||||
const double& x = normalizedPosition[0];
|
const double& x = normalizedPosition[0];
|
||||||
const double& y = normalizedPosition[1];
|
const double& y = normalizedPosition[1];
|
||||||
|
|
||||||
|
@ -47,7 +49,11 @@ public:
|
||||||
const unsigned int index = x_int + width * y_int;
|
const unsigned int index = x_int + width * y_int;
|
||||||
|
|
||||||
if(x_int < width && y_int < height) {
|
if(x_int < width && y_int < height) {
|
||||||
int_array[index]++;
|
if(normalizedColor[0] > 0.0){
|
||||||
|
int_array[index]++;
|
||||||
|
} else {
|
||||||
|
int_array[index + width*height]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +63,7 @@ public:
|
||||||
unsigned int* max_int = new unsigned int[num_colors];
|
unsigned int* max_int = new unsigned int[num_colors];
|
||||||
double* power = new double[num_colors];
|
double* power = new double[num_colors];
|
||||||
|
|
||||||
for(unsigned int i = 0; i < num_colors; i++) {
|
for(unsigned int i = 0; i < num_colors; ++i) {
|
||||||
max_int[i] = 0;
|
max_int[i] = 0;
|
||||||
double cumulative = 0;
|
double cumulative = 0;
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
|
@ -80,9 +86,8 @@ public:
|
||||||
LogInfo("negative power\n");
|
LogInfo("negative power\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(n < width) {
|
if(n < width) {
|
||||||
LogInfo("not enough data\n");
|
LogInfo("not enough data in dimension %d\n", i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +107,16 @@ public:
|
||||||
// pngFile->settext("Attractor", "Joshua Moerman", "A awesome attractor", "AwesomeAttractor");
|
// pngFile->settext("Attractor", "Joshua Moerman", "A awesome attractor", "AwesomeAttractor");
|
||||||
|
|
||||||
png::image< png::rgb_pixel > image(width, height);
|
png::image< png::rgb_pixel > image(width, height);
|
||||||
|
std::array<double, 6> power_matrix = {{
|
||||||
|
1.0, 1.5,
|
||||||
|
2.0, 2.5,
|
||||||
|
3.0, 1.5
|
||||||
|
}};
|
||||||
|
std::array<double, 6> output_matrix = {{
|
||||||
|
2.0, 2.0,
|
||||||
|
2.0, 1.5,
|
||||||
|
2.0, 2.0
|
||||||
|
}};
|
||||||
|
|
||||||
for(unsigned int x = 0; x < width; x++) {
|
for(unsigned int x = 0; x < width; x++) {
|
||||||
for(unsigned int y = 0; y < height; y++) {
|
for(unsigned int y = 0; y < height; y++) {
|
||||||
|
@ -110,22 +125,9 @@ public:
|
||||||
double b = 0.0;
|
double b = 0.0;
|
||||||
for(unsigned int c = 0; c < num_colors; c++) {
|
for(unsigned int c = 0; c < num_colors; c++) {
|
||||||
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
||||||
switch(c) {
|
r += (pow(norm_value, power[c]*power_matrix[c+0]))*output_matrix[c+0];
|
||||||
case 0: {
|
g += (pow(norm_value, power[c]*power_matrix[c+2]))*output_matrix[c+2];
|
||||||
r = (pow(norm_value, power[c]))*3.0;
|
b += (pow(norm_value, power[c]*power_matrix[c+4]))*output_matrix[c+4];
|
||||||
//break;
|
|
||||||
}
|
|
||||||
case 1: {
|
|
||||||
g = (pow(norm_value, power[c]*2.0))*3.0;
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
case 2: {
|
|
||||||
b = (pow(norm_value, power[c]*3.0))*3.0;
|
|
||||||
//break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// TODO: also clamp is below 0 ?
|
// TODO: also clamp is below 0 ?
|
||||||
r = std::min(1.0, r);
|
r = std::min(1.0, r);
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -89,7 +89,7 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Attractor& myAttractor = *my_attractor_ptr;
|
Attractor& myAttractor = *my_attractor_ptr;
|
||||||
myAttractor.projector->canvas = new PNG(width, height, 1);
|
myAttractor.projector->canvas = new PNG(width, height, 2);
|
||||||
myAttractor.init_range();
|
myAttractor.init_range();
|
||||||
|
|
||||||
LogInfo("\nRendering\n");
|
LogInfo("\nRendering\n");
|
||||||
|
|
|
@ -48,6 +48,7 @@ void Normalizer::project(const double* point) {
|
||||||
for(unsigned int i = 0; i < inputDimension; ++i) {
|
for(unsigned int i = 0; i < inputDimension; ++i) {
|
||||||
projectedPoint[i] = point[i]*factor + offset[i];
|
projectedPoint[i] = point[i]*factor + offset[i];
|
||||||
}
|
}
|
||||||
|
projectedColor[0] = sin(2.0 * point[2]);
|
||||||
|
|
||||||
if(!ready) {
|
if(!ready) {
|
||||||
static unsigned int state = 0;
|
static unsigned int state = 0;
|
||||||
|
|
Reference in a new issue