perlin_noise.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Mark Page
27 */
28 
29 
30 #pragma once
31 
32 #include "../api_display.h"
33 #include <memory>
34 #include "pixel_buffer.h"
35 
36 namespace clan
37 {
40 
41 class PerlinNoise_Impl;
42 
44 class CL_API_DISPLAY PerlinNoise
45 {
46 
49 
50 public:
52  PerlinNoise();
53 
55  virtual ~PerlinNoise();
56 
60 public:
61 
71  PixelBuffer create_noise1d(float start_x, float end_x);
72 
81  PixelBuffer create_noise2d(float start_x, float end_x, float start_y, float end_y);
82 
92  PixelBuffer create_noise3d(float start_x, float end_x, float start_y, float end_y, float z_position);
93 
104  PixelBuffer create_noise4d(float start_x, float end_x, float start_y, float end_y, float z_position, float w_position);
105 
107  Size get_size() const;
108 
110  TextureFormat get_format() const;
111 
113  float get_amplitude() const;
114 
116  int get_octaves() const;
117 
120 
127  void set_permutations(const unsigned char *table, unsigned int size = 256);
128 
135  void set_size(int width = 256, int height = 256);
136 
143  void set_size(const Size &size);
144 
152  void set_format(TextureFormat texture_format = tf_rgb8);
153 
159  void set_amplitude(float amplitude = 1.0f);
160 
166  void set_octaves(int octaves = 1);
167 
171 
172 private:
173  std::shared_ptr<PerlinNoise_Impl> impl;
174 };
175 
176 }
177 
Perlin Noise Generator class.
Definition: perlin_noise.h:44
Definition: texture_format.h:45
Pixel data container.
Definition: pixel_buffer.h:69
TextureFormat
Texture format.
Definition: texture_format.h:41
2D (width,height) size structure - Integer
Definition: size.h:157