Procedurality.Channel.boxFit C# (CSharp) Method

boxFit() public method

public boxFit ( float value, int width, int height ) : Channel
value float
width int
height int
return Channel
		public Channel boxFit(float value, int width, int height) {
			Channel channel = new Channel(this.width, this.height);
			bool match;
			for (int y = 0; y <= this.height - height; y++) {
				for (int x = 0; x <= this.width - width; x++) {
					match = true;
					for (int i = 0; i < width; i++) {
						for (int j = 0; j < height; j++) {
							match = match && (getPixel(x + i, y + j) == value);
							if (!match) break;
						}
					}
					if (match) {
						channel.putPixel(x, y, value);
					}
				}
			}
			pixels = channel.copy().pixels;
			return this;
		}