Procedurality.Channel.setMaxDelta C# (CSharp) Method

setMaxDelta() public method

public setMaxDelta ( float max ) : Channel
max float /// A ///
return Channel
		public Channel setMaxDelta(float max)
		{
			bool Altered=true;
			while(Altered)
			{
				Altered=false;
				//Console.WriteLine("Max so far: "+getMaxDelta().ToString());
				int x,y;
				for(x=0;x<Width-1;x++)
				{
					for(y=0;y<Height-1;y++)
					{
						float ch = getPixel(x,y);
						// Check neighbors.
						
						// North neighbor
						float nD = ch-getPixel(x,y+1);
						// East neighbor
						float eD = ch-getPixel(x+1,y);
						
						// Adjust, if needed.
						if(nD>max || eD>max)
						{
							pixels[y,x]-=0.01f;
							Altered=true;
						}
					}
				}
				for(x=1;x<Width;x++)
				{
					for(y=1;y<Height;y++)
					{
						float ch = getPixel(x,y);
						// Check neighbors.
						
						// South neighbor
						float sD = ch-getPixel(x,y-1);
						// West neighbor
						float wD = ch-getPixel(x-1,y);
						
						// Adjust, if needed.
						if(sD>max || wD>max)
						{
							pixels[y,x]-=0.01f;
							Altered=true;
						}
					}
				}
			}
			return this;
		}