コード例 #1
0
ファイル: Program.cs プロジェクト: hmmueller/Movimentum
        internal static int Interpret(Script script, string prefix)
        {
            IEnumerable<Frame> frames = script.CreateFrames();

            double range;
            {
                double maxDist = (script.Config.Width + script.Config.Height) * 10;
                range = maxDist * maxDist;
            }

            IDictionary<IVariable, VariableWithValue> previousState = new Dictionary<IVariable, VariableWithValue>();

            foreach (var f in frames) {
                var bitmap = new Bitmap(script.Config.Width, script.Config.Height);
                Graphics drawingPane = Graphics.FromImage(bitmap);

                // Compute locations for each anchor of each thing.
                Dictionary<string, double> debugExpectedResults;
                script.DebugExpectedResults.TryGetValue(f.FrameNo, out debugExpectedResults);
                IDictionary<string, IDictionary<string, ConstVector>> anchorLocations =
                    f.SolveConstraints(range, ref previousState, debugExpectedResults);
                foreach (var th in script.Things) {
                    th.Draw(drawingPane, anchorLocations[th.Name]);
                }

                bitmap.Save(string.Format("{0}{1:000000}.jpg", prefix, f.FrameNo), ImageFormat.Jpeg);
            }

            return frames.Count();
        }