-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoise_generator.h
66 lines (48 loc) · 1.55 KB
/
noise_generator.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
#ifndef NOISE_GENERATOR_H
#define NOISE_GENERATOR_H
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <map>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include "distance.h"
#include "color.h"
#define WIDTH 1680
#define HEIGHT 1050
class NoiseGenerator {
private:
std::map<std::string, std::function<sf::Color (int)> > colorFunctions;
std::map<std::string, std::function<int (int, int, int, int)> > distanceFunctions;
bool inverted;
bool invertColors;
int numberOfPoints;
DistanceFunc distanceFunc;
ColorFunc colorFunc;
std::vector<sf::Vector2i> points;
sf::Uint8 pixels[WIDTH * HEIGHT * 4];
sf::Vector2i topLeft;
sf::Texture texture;
sf::Sprite sprite;
int closestPoint(const sf::Vector2i& pixelLocation);
public:
NoiseGenerator(const sf::Vector2i& topLeft, int numPoints);
sf::Vector2i getTopLeft();
int getNumberOfPoints();
void setColorFunction(const std::string& colorFunction);
void setDistanceFunction(const std::string& distanceFunction);
void setTopLeft(const sf::Vector2i& topLeft);
void randomPoints(int count);
void setNumberOfPoints(int numberOfPoints);
void draw(sf::RenderWindow& window);
void generate();
void save(std::string path);
bool getInverted();
void setInverted(bool invert);
bool getInvertColors();
void setInvertColors(bool invert);
std::vector<std::string> getColorFunctions();
std::vector<std::string> getDistanceFunctions();
};
#endif