-
Notifications
You must be signed in to change notification settings - Fork 0
/
attractors.h
87 lines (61 loc) · 1.92 KB
/
attractors.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#ifndef __attractors_h_
#define __attractors_h_
//-----------------------------------------------------------------------------
#include <ostream>
namespace attractors {
typedef unsigned __int8 byte;
typedef unsigned __int16 word;
typedef unsigned __int32 uint;
typedef unsigned __int64 huge;
typedef double number;
class color {
public:
typedef color(*filter)(number);
static color hue(number h);
static color rainbow(number h);
static color monochrome(number h, const color& hue);
static color gradient(number h, const color& hue1, const color& hue2);
color(number r = 0, number g = 0, number b = 0) : red(r), green(g), blue(b) {}
inline color& operator+=(const color &rhs);
color operator+(const color &rhs) const;
void normalize();
public:
number red, green, blue;
};
struct point {
number x, y;
};
class image {
public:
image() = default;
image(int w, int h);
color* data() { return bitmap.data(); }
const color* data() const { return bitmap.data(); }
void resize(int w, int h);
void clear(); // clear content
void writetga(const wchar_t* filename, number sensitivity); // can be opened with gimp, PhotoShop, etc.
int nx, ny;
// TGA saving
static void tgaheader(std::ostream& os, int wdh, int hgt, const char* id = "");
static void tgafooter(std::ostream& os);
protected:
void update();
private:
std::vector<color> bitmap;
};
// geometry render interface
struct geometry {
virtual void render(
int quote, int pool,
image& img, // plotting image
color::filter hue, // Hue color generator
std::function<void()> notify // notify called with each per cent comlete
) const = 0;
// multithreaded render, returns duration in seconds
number rendermt(int pool, image& img, color::filter hue, bool notify = true) const;
};
}
//-----------------------------------------------------------------------------
#endif // __attractors_h_
// The End.