public static PatternStorage extractEveryPattern(ref Map source, int N, PatternVariation[] variations) { var patterns = new PatternStorage(source, N); var nVariations = variations.Length; // TODO: handling periodic input for (int y = 0; y < source.height - N + 1; y++) { for (int x = 0; x < source.width - N + 1; x++) { for (int i = 0; i < nVariations; i++) { patterns.store(x, y, variations[i]); } } } return(patterns); }
public static PatternStorage extractEveryChunk(ref Map source, int N, PatternVariation[] variations) { if (source.width % N != 0 || source.height % N != 0) { throw new System.Exception($"source size ({source.width}, {source.height}) must be dividable with N={N}"); } var patterns = new PatternStorage(source, N); var nVariations = variations.Length; var gridSize = new Vec2i(source.width, source.height) / N; for (int y = 0; y < gridSize.y; y++) { for (int x = 0; x < gridSize.x; x++) { for (int i = 0; i < nVariations; i++) { patterns.store(x * N, y * N, variations[i]); } } } return(patterns); }