Browse Source

added another example

master
Joshua Moerman 12 years ago
parent
commit
416f27a889
  1. 24
      ImageStreams/main.cpp

24
ImageStreams/main.cpp

@ -65,7 +65,7 @@ void automata(std::string filename){
std::vector<int> r1(width, 0);
std::vector<int> r2(width, 0);
r1[width/2] = 1;
r1[width/3] = 1;
ImageType image(width, height, filename);
for(int y = 0; y < height; ++y){
@ -78,6 +78,25 @@ void automata(std::string filename){
}
}
inline double logistic_step(double in, double c){
return c * in * (1.0 - in);
}
template <typename ImageType>
void logistic(std::string filename) {
size_t size = 800;
double x = 0.5;
double start = 3.7;
double end = 4.0;
ImageType image(size, size, filename);
for(int i = 0; i < size*size; ++i){
double c = start + i * (end - start) / (size*size);
// I know; the order of evaluation is implementation defined
image << typename ImageType::pixel(x = logistic_step(x, c), x = logistic_step(x, c), x = logistic_step(x, c));
}
}
int main(int argc, const char * argv[]){
xor_color<png::colored_ostream>("xor_color.png");
xor_color<bmp::colored_ostream>("xor_color.bmp");
@ -90,5 +109,8 @@ int main(int argc, const char * argv[]){
automata<png::gray_ostream>("automata.png");
automata<bmp::gray_ostream>("automata.bmp");
logistic<png::colored_ostream>("logistic.png");
logistic<bmp::colored_ostream>("logistic.bmp");
}