public static void WritePattern(Pattern pattern, string filename) { Proto.Pattern protoPattern = GenerateProtoPattern(pattern); using (var output = File.OpenWrite(filename)) { protoPattern.WriteTo(output); } }
private static Pattern GeneratePattern(Proto.Pattern protoPattern) { Pattern pattern = new Pattern(); pattern.FramesPerBeat = protoPattern.FramesPerBeat; pattern.UniqueCycles = protoPattern.UniqueCycles; for (int i = 0; i < protoPattern.Frames.Count; i++) { Frame frame = new Frame(i); for (int k = 0; k < protoPattern.Frames[i].Pixels.Count; k++) { frame.Pixels[k].Color = Int32ToColor(protoPattern.Frames[i].Pixels[k]); } pattern.Frames[i] = frame; } return(pattern); }
private static Proto.Pattern GenerateProtoPattern(Pattern pattern) { Proto.Pattern protoPattern = new Proto.Pattern(); protoPattern.Width = ConfigConstant.GetInt("FRAME_WIDTH"); protoPattern.Height = ConfigConstant.GetInt("FRAME_HEIGHT"); protoPattern.FramesPerBeat = pattern.FramesPerBeat; protoPattern.UniqueCycles = pattern.UniqueCycles; foreach (Frame frame in pattern.Frames) { Proto.Frame protoFrame = new Proto.Frame(); foreach (Pixel pixel in frame.Pixels) { protoFrame.Pixels.Add(ColorToInt32(pixel.Color)); } protoPattern.Frames.Add(protoFrame); } return(protoPattern); }