Procedurality.Channel.perturb C# (CSharp) Method

perturb() public method

public perturb ( Channel channel1, Channel channel2 ) : Channel
channel1 Channel
channel2 Channel
return Channel
		public Channel perturb(Channel channel1, Channel channel2) {
			Channel channel = new Channel(width, height);
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					float x_coord = x + width*channel1.getPixel(x, y);
					int x_coord_lo = (int)x_coord;
					int x_coord_hi = x_coord_lo + 1;
					float x_frac = x_coord - x_coord_lo;
					float y_coord = y + height*channel2.getPixel(x, y);
					int y_coord_lo = (int)y_coord;
					int y_coord_hi = y_coord_lo + 1;
					float y_frac = y_coord - y_coord_lo;
					float val1 = Tools.interpolateLinear(getPixelWrap(x_coord_lo, y_coord_lo), getPixelWrap(x_coord_hi, y_coord_lo), x_frac);
					float val2 = Tools.interpolateLinear(getPixelWrap(x_coord_lo, y_coord_hi), getPixelWrap(x_coord_hi, y_coord_hi), x_frac);
					channel.putPixel(x, y, Tools.interpolateLinear(val1, val2, y_frac));
				}
			}
			pixels = channel.getPixels();
			return this;
		}
		

Same methods

Channel::perturb ( Channel perturb, float magnitude ) : Channel