Procedurality.Channel.findMax C# (CSharp) Method

findMax() public method

public findMax ( ) : float
return float
		public float findMax() {
			float max = float.MinValue;
			float val = 0;
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					val = pixels[y,x];
					if (val > max) max = val;
				}
			}
			return max;
		}
	

Usage Example

コード例 #1
0
ファイル: Main.cs プロジェクト: N3X15/Procedurality4NET
        public static Channel CratersAlgo(int sizeX, int sizeY, int numCraters, int seed)
        {
            Channel chan = new Channel(sizeX, sizeY);
            Console.WriteLine();
            Random rand = new Random(seed);
            for (int i = 0; i < numCraters; )
            {
                int x = rand.Next(0, sizeX);
                int y = rand.Next(0, sizeY);
                double radius = (rand.NextDouble() * 84.0) - 20;

                // Clamp
                //x=(x<0) ? 0 : ((x>size-1) ? size-1 : x);
                //x=(y<0) ? 0 : ((y>size-1) ? size-1 : y);
                //radius=(radius<20.0) ? 20.0 : ((radius>84.0) ? 84.0 : radius);

                Channel crater = (new Crater(sizeX, sizeY, x, y, radius)).toChannel();
                if (crater.findMax() != 1.0)
                {
                    continue;
                }
                //if(crater.findMin()!=0.0)
                //{
                //	Console.Write("!");
                //	continue;
                //}
                i++;
                drawTextProgressBar(i, numCraters);
                //crater.toLayer().saveAsPNG("../sims/crater_debug.png");
                chan.channelAdd(crater.normalize(-0.01f, 0.01f));
            }
            chan.normalize();
            Console.WriteLine("\nRange [{0},{1}]", chan.findMin(), chan.findMax());
            return chan;
        }
All Usage Examples Of Procedurality.Channel::findMax