perlin_noise.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore 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 UICore may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Mark Page
27 */
28 
29 #pragma once
30 
31 #include <memory>
32 #include "pixel_buffer.h"
33 
34 namespace uicore
35 {
38  {
39  public:
41  static std::shared_ptr<PerlinNoise> create();
42 
52  virtual PixelBufferPtr create_noise1d(float start_x, float end_x) = 0;
53 
62  virtual PixelBufferPtr create_noise2d(float start_x, float end_x, float start_y, float end_y) = 0;
63 
73  virtual PixelBufferPtr create_noise3d(float start_x, float end_x, float start_y, float end_y, float z_position) = 0;
74 
85  virtual PixelBufferPtr create_noise4d(float start_x, float end_x, float start_y, float end_y, float z_position, float w_position) = 0;
86 
88  virtual Size size() const = 0;
89 
91  virtual TextureFormat format() const = 0;
92 
94  virtual float amplitude() const = 0;
95 
97  virtual int octaves() const = 0;
98 
105  virtual void set_permutations(const unsigned char *table, unsigned int size = 256) = 0;
106 
113  void set_size(int width = 256, int height = 256) { set_size(Size(width, height)); }
114 
121  virtual void set_size(const Size &size) = 0;
122 
130  virtual void set_format(TextureFormat texture_format = tf_rgb8) = 0;
131 
137  virtual void set_amplitude(float amplitude = 1.0f) = 0;
138 
144  virtual void set_octaves(int octaves = 1) = 0;
145  };
146 
147  typedef std::shared_ptr<PerlinNoise> PerlinNoisePtr;
148 }
2D (width,height) size structure - Integer
Definition: size.h:167
virtual void set_format(TextureFormat texture_format=tf_rgb8)=0
Set the format of the output pixelbuffer.
virtual void set_amplitude(float amplitude=1.0f)=0
Set the amplitude of the perlin noise.
virtual PixelBufferPtr create_noise1d(float start_x, float end_x)=0
Create the perlin noise.
virtual PixelBufferPtr create_noise2d(float start_x, float end_x, float start_y, float end_y)=0
Create the perlin noise.
TextureFormat
Texture format.
Definition: texture_format.h:35
std::shared_ptr< PerlinNoise > PerlinNoisePtr
Definition: perlin_noise.h:147
virtual void set_permutations(const unsigned char *table, unsigned int size=256)=0
Set the permutation table.
virtual PixelBufferPtr create_noise3d(float start_x, float end_x, float start_y, float end_y, float z_position)=0
Create the perlin noise.
virtual PixelBufferPtr create_noise4d(float start_x, float end_x, float start_y, float end_y, float z_position, float w_position)=0
Create the perlin noise.
virtual int octaves() const =0
Get the number of octaves of the perlin noise.
static std::shared_ptr< PerlinNoise > create()
Constructor.
virtual float amplitude() const =0
Get the amplitude of the perlin noise.
virtual Size size() const =0
Get the size of the output pixelbuffer.
virtual TextureFormat format() const =0
Get the format of the output pixelbuffer.
std::shared_ptr< PixelBuffer > PixelBufferPtr
Definition: d3d_target.h:39
Perlin Noise Generator class.
Definition: perlin_noise.h:37
Definition: texture_format.h:39
virtual void set_octaves(int octaves=1)=0
Set the number of octaves of the perlin noise.
Definition: Application/application.h:35
void set_size(int width=256, int height=256)
Set the size of the output pixelbuffer.
Definition: perlin_noise.h:113