Smooth 2D Noise Viewer
Perlin and Value Noise
CMain.cpp
Go to the documentation of this file.
1
3
4// MIT License
5//
6// Copyright (c) 2022 Ian Parberry
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to
10// deal in the Software without restriction, including without limitation the
11// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12// sell copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25
26#include <random>
27#include <algorithm>
28
29#include "CMain.h"
30#include "WindowsHelpers.h"
31#include "Perlin.h"
32#include "Defines.h"
33#include "Helpers.h"
34
36// Constructors and destructors
37
38#pragma region Constructors and destructors
39
42
43CMain::CMain(const HWND hwnd): m_hWnd(hwnd){
44 m_gdiplusToken = InitGDIPlus(); //initialize GDI+
45 m_pPerlin = new CPerlinNoise2D(); //Perlin noise generator
46 CreateMenus(); //create the menu bar
47} //constructor
48
50
52 delete m_pPerlin; //delete the Perlin noise generator
53 delete m_pBitmap; //delete the bitmap
54 Gdiplus::GdiplusShutdown(m_gdiplusToken); //shut down GDI+
55} //destructor
56
57#pragma endregion Constructors and destructors
58
60// Drawing functions
61
62#pragma region Drawing functions
63
66
68 PAINTSTRUCT ps; //paint structure
69 HDC hdc = BeginPaint(m_hWnd, &ps); //device context
70 Gdiplus::Graphics graphics(hdc); //GDI+ graphics object
71
72 //get bitmap width and height
73
74 const int nBitmapWidth = m_pBitmap->GetWidth();
75 const int nBitmapHeight = m_pBitmap->GetHeight();
76
77 //get client rectangle
78
79 RECT rectClient; //for client rectangle
80 GetClientRect(m_hWnd, &rectClient); //get client rectangle
81 const int nClientWidth = rectClient.right - rectClient.left; //client width
82 const int nClientHeight = rectClient.bottom - rectClient.top; //client height
83
84 //compute destination rectangle
85
86 const int nDestSide = min(nClientWidth, nClientHeight); //dest width and ht
87
88 const int width = min(nDestSide, nBitmapWidth); //dest rect width
89 const int height = min(nDestSide, nBitmapHeight); //dest rect height
90
91 const int x = max(0, nClientWidth - width)/2; //x margin
92 const int y = max(0, nClientHeight - height)/2; //y margin
93
94 Gdiplus::Rect rectDest(x, y, width, height); //destination rectangle
95
96 //draw image to destination rectangle then clean up
97
98 graphics.DrawImage(m_pBitmap, rectDest);
99
100 EndPaint(m_hWnd, &ps); //this must be done last
101} //OnPaint
102
103#pragma endregion Drawing functions
104
106// Menu functions
107
108#pragma region Menu functions
109
111
113 HMENU hMenubar = CreateMenu();
114
115 m_hFileMenu = CreateFileMenu(hMenubar);
116 m_hGenMenu = CreateGenerateMenu(hMenubar);
117 m_hViewMenu = CreateViewMenu(hMenubar);
119 m_hHashMenu = CreateHashMenu(hMenubar);
121 m_hSetMenu = CreateSettingsMenu(hMenubar);
122 CreateHelpMenu(hMenubar);
123
124 SetMenu(m_hWnd, hMenubar);
125 UpdateMenus();
126} //CreateMenus
127
130
139
140 //update individual menu items
141
143 m_fOriginX == 0.0f && m_fOriginY == 0.0f);
144
154
162} //UpdateMenus
163
164#pragma endregion Menu functions
165
167// Bitmap functions
168
169#pragma region Bitmap functions
170
174
175void CMain::CreateBitmap(int w, int h){
176 delete m_pBitmap; //safety
177 m_pBitmap = new Gdiplus::Bitmap(w, h); //create bitmap
178 ClearBitmap(Gdiplus::Color::White); //clear bitmap to white
179} //CreateBitmap
180
183
184void CMain::ClearBitmap(Gdiplus::Color clr){
185 Gdiplus::Graphics graphics(m_pBitmap); //for editing
186 graphics.Clear(clr); //clear to white
187} //Clear
188
195
196void CMain::SetPixel(UINT i, UINT j, float g){
197 SetPixel(i, j, BYTE(float(0xFF)*(g/2 + 0.5f)));
198} //SetPixel
199
206
207void CMain::SetPixel(UINT i, UINT j, BYTE b){
208 SetPixel(i, j, Gdiplus::Color(255, b, b, b));
209} //SetPixel
210
216
217void CMain::SetPixel(UINT i, UINT j, Gdiplus::Color clr){
218 m_pBitmap->SetPixel(i, j, clr);
219} //SetPixel
220
221#pragma endregion Bitmap functions
222
224// Noise generation functions
225
226#pragma region Noise generation functions
227
232
234 m_eNoise = t; //remember the noise type
235 UpdateMenus(); //changing noise type may change the menu status
236
237 m_fMin = 1000.0f; //init noise minima to something stupidly large
238 m_fMax = -1000.0f; //init noise maxima to something stupidly small
239 m_fAve = 0.0f; //init sum for average
240
241 const UINT w = m_pBitmap->GetWidth(); //bitmap width
242 const UINT h = m_pBitmap->GetHeight(); //bitmap height
243
244 for(UINT i=0; i<w; i++){
245 const float x = m_fOriginX + i/m_fScale; //noise X-coordinate
246
247 for(UINT j=0; j<h; j++){
248 const float y = m_fOriginY + j/m_fScale; //noise Y-coordinate
249 const float noise = m_pPerlin->generate(x, y, t, m_nOctaves); //noise
250 SetPixel(i, j, noise); //draw noise pixel to bitmap
251
252 //recompute maximum, minimum, and average
253 m_fMin = min(m_fMin, noise);
254 m_fMax = max(m_fMax, noise);
255 m_fAve += noise;
256 } //for
257 } //for
258
259 m_fAve /= w*h; //compute average from sum
260
263} //GenerateNoiseBitmap
264
272
273void CMain::GenerateNoiseBitmap(Gdiplus::PointF point, Gdiplus::RectF rect){
274 const UINT nLeft = (UINT)floorf(rect.GetLeft() + point.X);
275 const UINT nRight = (UINT)ceilf(rect.GetRight() + point.X);
276 const UINT nTop = (UINT)floorf(rect.GetTop() + point.Y);
277 const UINT nBottom = (UINT)ceilf(rect.GetBottom() + point.Y);
278
279 for(UINT i=nLeft; i<nRight; i++){
280 const float x = m_fOriginX + i/m_fScale;
281
282 for(UINT j=nTop; j<nBottom; j++){
283 const float y = m_fOriginY + j/m_fScale;
285 } //for
286 } //for
287} //GenerateNoiseBitmap
288
296
298 Gdiplus::FontFamily ff(L"Arial");
299 Gdiplus::Font font(&ff, 20, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel);
300 Gdiplus::SolidBrush brush(Gdiplus::Color::White);
301
302 Gdiplus::Graphics graphics(m_pBitmap);
303
304 //top left corner coordinates
305
306 Gdiplus::PointF point(0.0f, 0.0f); //text position on screen
307
308 std::wstring wstr = L"("; //text of origin coordinates
309 wstr += std::to_wstring((size_t)floorf(m_fOriginX)) + L", ";
310 wstr += std::to_wstring((size_t)floorf(m_fOriginY)) + L")";
311
312 Gdiplus::RectF rect, unused;
313 graphics.MeasureString(wstr.c_str(), -1, &font, unused, &rect); //measure text
314
315 if(m_bShowCoords) //draw
316 graphics.DrawString(wstr.c_str(), -1, &font, point, &brush);
317 else GenerateNoiseBitmap(point, rect); //undraw
318
319 //bottom right corner coordinates
320
321 const float x = m_fOriginX + m_pBitmap->GetWidth()/m_fScale; //x-coordinate
322 const float y = m_fOriginY + m_pBitmap->GetHeight()/m_fScale; //y-coordinate
323
324 wstr = L"(" + to_wstring_f(x, 2) + L", " + to_wstring_f(y, 2) + L")"; //text
325
326 graphics.MeasureString(wstr.c_str(), -1, &font, unused, &rect); //measure text
327 point.X = m_pBitmap->GetWidth() - rect.Width; //text x-coordinate on screen
328 point.Y = m_pBitmap->GetHeight() - rect.Height; //text y-coordinate on screen
329
330 if(m_bShowCoords) //draw
331 graphics.DrawString(wstr.c_str(), -1, &font, point, &brush);
332 else GenerateNoiseBitmap(point, rect); //undraw
333
335 DrawGrid(); //in case we erased part of the grid lines
336} //DrawCoords
337
343
345 const float fBitmapWidth = (float)m_pBitmap->GetWidth();
346 const float fBitmapHeight = (float)m_pBitmap->GetHeight();
347
348 const UINT nv = (UINT)floorf(fBitmapWidth/m_fScale); //number of vertical lines
349 const UINT nh = (UINT)floorf(fBitmapHeight/m_fScale); //number of horizontal lines
350
351 Gdiplus::Graphics graphics(m_pBitmap);
352 Gdiplus::Pen pen(Gdiplus::Color(255, 0, 255, 0)); //green
353
354 //horizontal lines
355
356 Gdiplus::PointF left(0.0f, m_fScale); //left X-coordinate of line
357 Gdiplus::PointF right(fBitmapWidth, m_fScale); //right X-coordinate of line
358 Gdiplus::RectF rect(0.0f, 0.0f, fBitmapWidth, 1.0f); //bounding rectangle
359
360 for(UINT i=0; i<nh; i++){ //for each horizontal line
361 if(m_bShowGrid)graphics.DrawLine(&pen, left, right); //draw line
362 else GenerateNoiseBitmap(left, rect); //undraw line
363
364 //move down to next horizontal line
365 left.Y += m_fScale;
366 right.Y += m_fScale;
367 } //for
368
369 //vertical lines
370
371 Gdiplus::PointF top(m_fScale, 0.0f); //top Y-coordinate of line
372 Gdiplus::PointF bottom(m_fScale, fBitmapHeight); //bottom Y-coordinate of line
373 rect = Gdiplus::RectF(0.0f, 0.0f, 1.0f, fBitmapHeight); //bounding rectangle
374
375 for(UINT i=0; i<nv; i++){ //for each vertical line
376 if(m_bShowGrid)graphics.DrawLine(&pen, top, bottom); //draw line
377 else GenerateNoiseBitmap(top, rect); //undraw line
378
379 //move right to next vertical line
380 top.X += m_fScale;
381 bottom.X += m_fScale;
382 } //for
383
385 DrawCoords(); //in case we erased some of the coordinate text
386} //DrawGrid
387
390
393} //GenerateNoiseBitmap
394
395#pragma endregion Noise generation functions
396
398// Menu response functions
399
400#pragma region Menu response functions
401
405
410} //Randomize
411
416
418 if(m_pPerlin->GetDistribution() != d){
422 return true;
423 } //if
424
425 return false;
426} //SetDistribution
427
430
435} //SetSpline
436
439
441 m_pPerlin->SetHash(d);
444} //SetHash
445
448
452 DrawCoords();
453} //ToggleViewCoords
454
457
461 DrawGrid();
462} // ToggleViewGrid
463
466
468 const float offset = (float)m_pPerlin->GetTableSize();
469 m_fOriginX += offset;
470 m_fOriginY += offset;
472} //Jump
473
477
478void CMain::Jump(float x, float y){
479 m_fOriginX = x;
480 m_fOriginY = y;
482} //Jump
483
488
489const bool CMain::Origin(float x, float y) const{
490 return m_fOriginX == x && m_fOriginY == y;
491} //Origin
492
495
497 m_nOctaves = std::min<size_t>(m_nOctaves + 1, m_nMaxOctaves);
499} //IncreaseOctaves
500
503
505 m_nOctaves = std::max<size_t>(m_nMinOctaves, m_nOctaves - 1);
507} //DecreaseOctaves
508
511
513 m_fScale = std::min<float>(2.0f*m_fScale, m_fMaxScale);
515} //IncreaseScale
516
519
521 m_fScale = std::max<float>(m_fMinScale, m_fScale/2.0f);
523} //DecreaseScale
524
526
530} //IncreaseTableSize
531
533
537} //DecreaseTableSize
538
541
547} //Reset
548
549#pragma endregion Menu response functions
550
552// Reader functions
553
554#pragma region Reader functions
555
558
559const std::wstring CMain::GetFileName() const{
560 std::wstring wstr;
561
562 switch(m_eNoise){
563 case eNoise::Perlin: wstr = L"Perlin"; break;
564 case eNoise::Value: wstr = L"Value"; break;
565 } //switch
566
567 switch(m_pPerlin->GetHash()){
568 case eHash::Permutation: wstr += L"-Perm"; break;
569 case eHash::LinearCongruential: wstr += L"-Lin"; break;
570 case eHash::Std: wstr += L"-Std"; break;
571 } //switch
572
573 switch(m_pPerlin->GetDistribution()){
574 case eDistribution::Uniform: break; //nothing, which is the default
575 case eDistribution::Maximal: wstr += L"-Max"; break;
576 case eDistribution::Cosine: wstr += L"-Cos"; break;
577 case eDistribution::Normal: wstr += L"-Norm"; break;
578 case eDistribution::Exponential: wstr += L"-Exp"; break;
579 case eDistribution::Midpoint: wstr += L"-Mid"; break;
580 } //switch
581
582 switch(m_pPerlin->GetSpline()){
583 case eSpline::None: wstr += L"-NoSpline"; break;
584 case eSpline::Cubic: break; //nothing, which is the default
585 case eSpline::Quintic: wstr += L"-Quintic"; break;
586 } //switch
587
588 wstr += L"-" + std::to_wstring(m_nOctaves);
589 wstr += L"-" + std::to_wstring(m_pPerlin->GetTableSize());
590 wstr += L"-" + std::to_wstring((size_t)round(m_fScale));
591
592 return wstr;
593} //GetFileName
594
597
598const std::wstring CMain::GetNoiseDescription() const{
599 std::wstring wstr; //for noise description
600
601 //number of octaves
602
603 if(m_eNoise == eNoise::Perlin || m_eNoise == eNoise::Value){
604 wstr += std::to_wstring(m_nOctaves) + L" octave";
605 if(m_nOctaves > 1)wstr += L"s";
606 wstr += L" of ";
607 } //if
608
609 //type of noise
610
611 switch(m_eNoise){
612 case eNoise::Perlin: wstr += L"Perlin"; break;
613 case eNoise::Value: wstr += L"Value"; break;
614 } //switch
615
616 wstr += L" Noise";
617
618 //origin
619
620 wstr += L" with origin (";
621 wstr += to_wstring_f(m_fOriginX, 2) + L", ";
622 wstr += to_wstring_f(m_fOriginY, 2) + L"), ";
623
624 //hash function
625
626 switch(m_pPerlin->GetHash()){
627 case eHash::Permutation: wstr += L"a permutation"; break;
628 case eHash::LinearCongruential: wstr += L"linear congruential"; break;
629 case eHash::Std: wstr += L"std"; break;
630 } //switch
631
632 wstr += L" hash function, ";
633
634 //distribution
635
636 switch(m_pPerlin->GetDistribution()){
637 case eDistribution::Uniform: wstr += L"uniform"; break;
638 case eDistribution::Maximal: wstr += L"maximal"; break;
639 case eDistribution::Cosine: wstr += L"cosine"; break;
640 case eDistribution::Normal: wstr += L"normal"; break;
641 case eDistribution::Exponential: wstr += L"exponential"; break;
642 case eDistribution::Midpoint: wstr += L"midpoint displacement"; break;
643 } //switch
644
645 switch(m_eNoise){
646 case eNoise::Perlin: wstr += L" gradient"; break;
647 case eNoise::Value: wstr += L" height"; break;
648 } //switch
649
650 wstr += L" distribution, ";
651
652 //spline function
653
654 switch(m_pPerlin->GetSpline()){
655 case eSpline::None: wstr += L"no"; break;
656 case eSpline::Cubic: wstr += L"cubic"; break;
657 case eSpline::Quintic: wstr += L"quintic"; break;
658 } //switch
659
660 wstr += L" spline function, ";
661
662 //scale
663
664 wstr += L"scale " + std::to_wstring((size_t)round(m_fScale)) + L", and ";
665
666 //table size
667
668 if(m_pPerlin->GetHash() == eHash::Permutation)
669 wstr += L"permutation and ";
670
671 switch(m_eNoise){
672 case eNoise::Perlin: wstr += L"gradient "; break;
673 case eNoise::Value: wstr += L"value "; break;
674 } //switch
675
676 wstr += L"table size ";
677 wstr += std::to_wstring(m_pPerlin->GetTableSize());
678 wstr += L". ";
679
680 //noise max, min, and average
681
682 wstr += L"Largest generated noise ";
683 wstr += to_wstring_f(m_fMax, 4) + L". ";
684 wstr += L"Smallest generated noise ";
685 wstr += to_wstring_f(m_fMin, 4) + L". ";
686 wstr += L"Average generated noise ";
687 wstr += to_wstring_f(m_fAve, 4) + L".";
688
689 return wstr;
690} //GetNoiseDescription
691
694
695Gdiplus::Bitmap* CMain::GetBitmap() const{
696 return m_pBitmap;
697} //GetBitmap
698
699#pragma endregion Reader functions
Interface for the main class CMain.
Useful defines, constants, and types.
eDistribution
Distribution.
Definition: Defines.h:54
eSpline
Spline type.
Definition: Defines.h:62
eHash
Hash function type.
Definition: Defines.h:46
eNoise
Perlin noise type.
Definition: Defines.h:38
std::wstring to_wstring_f(float x, size_t n)
Float to fixed precision wstring.
Definition: Helpers.cpp:76
Interface for helper functions.
HMENU CreateViewMenu(HMENU hMenubar)
Create View menu.
void UpdateGenerateMenu(HMENU hMenu, eNoise noise)
Update Generate menu.
HMENU CreateSplineMenu(HMENU hMenubar)
Create Spline menu.
HMENU CreateHashMenu(HMENU hMenubar)
Create Hash menu.
void UpdateHashMenu(HMENU hMenu, eNoise noise, eHash h)
Update Hash menu.
void UpdateViewMenu(HMENU hMenu, eNoise noise)
Update View menu.
HMENU CreateDistributionMenu(HMENU hMenubar)
Create Distribution menu.
void UpdateSettingsMenu(HMENU hMenu, eNoise noise)
Update Settings menu.
HMENU CreateSettingsMenu(HMENU hMenubar)
Create Settings menu.
void UpdateSplineMenu(HMENU hMenu, eNoise noise, eSpline spline)
Update Spline menu.
void UpdateMenuItemGray(HMENU hMenu, UINT item, eNoise noise, bool bGray)
Update menu item bool.
ULONG_PTR InitGDIPlus()
Initialize GDI+.
void UpdateFileMenu(HMENU hMenu, eNoise noise)
Update File menu.
HMENU CreateFileMenu(HMENU hMenubar)
Create File menu.
void UpdateDistributionMenu(HMENU hMenu, eNoise noise, eDistribution distr)
Update Distribution menu.
void UpdateMenuItemCheck(HMENU hMenu, UINT item, bool bCheck)
Update menu item check.
void CreateHelpMenu(HMENU hMenubar)
Create Help menu.
HMENU CreateGenerateMenu(HMENU hMenubar)
Create Generate menu.
Interface for some helpful Windows-specific functions.
#define IDM_SETTINGS_TSIZE_UP
Menu id for table size up.
#define IDM_VIEW_GRID
Menu id for view grid.
#define IDM_SETTINGS_SCALE_UP
Menu id for scale up.
#define IDM_SETTINGS_SCALE_DN
Menu id for scale down.
#define IDM_SETTINGS_RESET
Menu id for reset settings.
#define IDM_SETTINGS_TSIZE_DN
Menu id for table size down.
void UpdateMenuItem(HMENU hMenu, UINT up, UINT dn, eNoise noise, t n, t nMin, t nMax)
Update a numeric menu item.
#define IDM_SETTINGS_OCTAVE_UP
Menu id for octave up.
#define IDM_SETTINGS_OCTAVE_DN
Menu id for octave down.
#define IDM_VIEW_COORDS
Menu id for view coordinates.
#define IDM_GENERATE_RESETORIGIN
Menu id for reset origin.
void ClearBitmap(Gdiplus::Color)
Clear bitmap to color.
Definition: CMain.cpp:184
CPerlinNoise2D * m_pPerlin
Pointer to Perlin noise generator.
Definition: CMain.h:76
HMENU m_hGenMenu
Handle to the Generate menu.
Definition: CMain.h:46
const std::wstring GetNoiseDescription() const
Get noise description.
Definition: CMain.cpp:598
void CreateMenus()
Create menus.
Definition: CMain.cpp:112
HMENU m_hSplineMenu
Handle to the Spline menu.
Definition: CMain.h:51
float m_fScale
Scale.
Definition: CMain.h:65
void DecreaseScale()
Decrease scale.
Definition: CMain.cpp:520
HMENU m_hDistMenu
Handle to the Distribution menu.
Definition: CMain.h:49
void GenerateNoiseBitmap()
Generate bitmap again with saved parameters.
Definition: CMain.cpp:391
void DrawGrid()
Draw grid to bitmap.
Definition: CMain.cpp:344
eNoise m_eNoise
Noise type.
Definition: CMain.h:54
bool m_bShowCoords
Show coordinates flag.
Definition: CMain.h:78
const float m_fMaxScale
Minimum scale.
Definition: CMain.h:67
const std::wstring GetFileName() const
Get noise file name.
Definition: CMain.cpp:559
const size_t m_nMaxOctaves
Maximum number of octaves of noise.
Definition: CMain.h:62
HMENU m_hFileMenu
Handle to the File menu.
Definition: CMain.h:45
void CreateBitmap(int w, int h)
Create bitmap.
Definition: CMain.cpp:175
void Randomize()
Randomize PRNG.
Definition: CMain.cpp:406
float m_fMax
Largest noise value in generated noise.
Definition: CMain.h:70
void Reset()
Reset number of octaves, scale, table size.
Definition: CMain.cpp:542
void UpdateMenus()
Update menus.
Definition: CMain.cpp:131
~CMain()
Destructor.
Definition: CMain.cpp:51
void DrawCoords()
Draw coordinates to bitmap.
Definition: CMain.cpp:297
bool SetDistribution(eDistribution)
Set probability distribution.
Definition: CMain.cpp:417
HMENU m_hHashMenu
Handle to the Hash menu.
Definition: CMain.h:50
void DecreaseTableSize()
Decrease table size.
Definition: CMain.cpp:534
float m_fAve
Average noise value in generated noise.
Definition: CMain.h:71
float m_fOriginX
X-coordinate of top.
Definition: CMain.h:56
CMain(const HWND hwnd)
Constructor.
Definition: CMain.cpp:43
void ToggleViewCoords()
Toggle View Coordinates flag.
Definition: CMain.cpp:449
float m_fOriginY
Y-coordinate of left.
Definition: CMain.h:57
const size_t m_nMinOctaves
Minimum number of octaves of noise.
Definition: CMain.h:61
void IncreaseTableSize()
Increase table size.
Definition: CMain.cpp:527
const size_t m_nDefOctaves
Default number of octaves of noise.
Definition: CMain.h:59
ULONG_PTR m_gdiplusToken
GDI+ token.
Definition: CMain.h:73
Gdiplus::Bitmap * GetBitmap() const
Get pointer to bitmap.
Definition: CMain.cpp:695
const float m_fMinScale
Minimum scale.
Definition: CMain.h:66
void SetHash(eHash)
Set hash function.
Definition: CMain.cpp:440
void DecreaseOctaves()
Decrease number of octaves.
Definition: CMain.cpp:504
void Jump()
Change origin coordinates.
Definition: CMain.cpp:467
HMENU m_hViewMenu
Handle to the View menu.
Definition: CMain.h:47
bool m_bShowGrid
Show grid flag.
Definition: CMain.h:79
void ToggleViewGrid()
Toggle View Grid flag.
Definition: CMain.cpp:458
HMENU m_hSetMenu
Handle to the Settings menu.
Definition: CMain.h:48
void SetSpline(eSpline)
Set spline function.
Definition: CMain.cpp:431
void IncreaseOctaves()
Increase number of octaves.
Definition: CMain.cpp:496
const bool Origin(float x, float y) const
Check origin coordinates.
Definition: CMain.cpp:489
Gdiplus::Bitmap * m_pBitmap
Pointer to a bitmap image.
Definition: CMain.h:75
void OnPaint()
Paint the client area of the window.
Definition: CMain.cpp:67
size_t m_nOctaves
Number of octaves of noise.
Definition: CMain.h:60
const float m_fDefScale
Default scale.
Definition: CMain.h:64
void SetPixel(UINT, UINT, float)
Set pixel grayscale from float.
Definition: CMain.cpp:196
void IncreaseScale()
Increase scale.
Definition: CMain.cpp:512
HWND m_hWnd
Window handle.
Definition: CMain.h:43
float m_fMin
Smallest noise value in generated noise.
Definition: CMain.h:69
2D Perlin and Value noise generator.
Definition: perlin.h:48
const size_t GetMinTableSize() const
Get minimum table size.
Definition: perlin.cpp:588
const eSpline GetSpline() const
Get spline function type.
Definition: perlin.cpp:616
void SetHash(eHash)
Set hash function.
Definition: perlin.cpp:309
const size_t GetMaxTableSize() const
Get maximum table size.
Definition: perlin.cpp:595
const size_t GetTableSize() const
Get table size.
Definition: perlin.cpp:581
bool DefaultTableSize()
Set table size to default.
Definition: perlin.cpp:278
void SetSpline(eSpline)
Set spline function.
Definition: perlin.cpp:302
const float generate(float, float, eNoise, size_t, float=0.5f, float=2.0f) const
Generate noise at a point.
Definition: perlin.cpp:548
void RandomizeTable(eDistribution)
Randomize table from distribution.
Definition: perlin.cpp:227
const eHash GetHash() const
Get hash function type.
Definition: perlin.cpp:609
bool DoubleTableSize()
Double table size.
Definition: perlin.cpp:245
const eDistribution GetDistribution() const
Get distribution type.
Definition: perlin.cpp:623
bool HalveTableSize()
Halve table size.
Definition: perlin.cpp:262
const size_t GetDefTableSize() const
Get default table size.
Definition: perlin.cpp:602
void SetSeed()
Set seed for PRNG.
Definition: perlin.cpp:295
Interface for the Perlin and Value noise generators.