Procedurality.Channel.squareFit C# (CSharp) Method

squareFit() public method

public squareFit ( float value, int size ) : Channel
value float
size int
return Channel
		public Channel squareFit(float value, int size) {
			Channel channel = new Channel(width, height);
			bool match;
			for (int y = 0; y <= height - size; y++) {
				for (int x = 0; x <= width - size; x++) {
					match = true;
					for (int i = 0; i < size; i++) {
						for (int j = 0; j < size; 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;
		}