-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlyExp.cpp
62 lines (51 loc) · 1.3 KB
/
lyExp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "EasyBMP.hpp"
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
using namespace EasyBMP;
double ly(double a, double b){
double r = a;
double sum = 0;
double xn = .5;
for(int i = 1; i < 750; i++){
if (xn != .5){
sum += log(abs(r*(1-(2*xn))));
}
xn = r*xn*(1-xn);
if (r == a){
r = b;
}else{
r = a;
}
}
return (1/750.0) * sum;
}
RGBColor getC(double n){
if (n < 0){
return RGBColor(0, 0, (int)((n*100+255)));
}
if (n > 0){
return RGBColor((int)((n*300*1.225+255)), 0, 0);
}
return RGBColor(0, 0, 0);
}
int main(){
int width = 88;
int height = 31;
vector<double> aR = {3.4,4};
vector<double> bR = {3.3,4};
vector<double> all;
Image i(width, height, "test.bmp", RGBColor (0, 0, 0));
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
double a = ((y/(double) height) * (aR[1] - aR[0])) + aR[0];
double b = ((x/(double) width) * (bR[1] - bR[0])) + bR[0];
double lyExp = ly(a,b);
i.SetPixel(x, height-y-1, getC(lyExp));
}
}
i.Write();
return 0;
}