Procedurality.Channel.channelAdd C# (CSharp) Method

channelAdd() public method

public channelAdd ( Channel channel ) : Channel
channel Channel
return Channel
		public Channel channelAdd(Channel channel) {
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					try
					{
						putPixelClip(x, y, getPixel(x, y) + channel.getPixel(x, y));
					} catch(Exception) {
						putPixelClip(x,y,0f);
						Console.WriteLine("Failed to get pixel ("+x.ToString()+","+y.ToString()+").");
					}
				}
			}
			return this;
		}
	

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::channelAdd