Exemplo n.º 1
0
        private static void DoEffectByEffectName(Effector effector, Task task)
        {
            if (task.cut_pos_x != null && task.cut_pos_y != null)
            {
                effector.AddLayer(task.cut_file,
                                  Int32.Parse(task.cut_pos_x), Int32.Parse(task.cut_pos_y));
            }
            else
            {
                effector.AddLayer(task.cut_file); // will produces centered image
            }
            var effectToBeParsed = task.parameters;

            switch (task.effect_name)
            {
            case "earthquake":
                var param = JsonConvert.DeserializeObject <Earthquake>(task.parameters);
                Console.WriteLine(" [i] make earthquake with param [power: {0}, speed: {1}, time: {2}]",
                                  param.power, param.speed, param.time);
                effector.Earthquake(param.power, param.speed, param.time);
                break;

            case "appear":
                var aparam = JsonConvert.DeserializeObject <Appear>(task.parameters);
                Console.WriteLine(" [i] make appear with param [time: {0}]",
                                  aparam.time);
                effector.None(aparam.time);
                break;

            case "shake":
                var sparam = JsonConvert.DeserializeObject <Shake>(task.parameters);
                Console.WriteLine(" [i] make shake with param [degree: {0}, speed: {1}, count: {2}]",
                                  sparam.degree, sparam.speed, sparam.count);
                effector.Shake(sparam.degree, sparam.speed, sparam.count);
                break;

            case "rotate":
                var rparam = JsonConvert.DeserializeObject <Rotate>(task.parameters);
                Console.WriteLine(" [i] make rotate with param [degree: {0}, way: {1}, speed: {2}]",
                                  rparam.degree, rparam.way ? "clockwise" : "counter-clockwise", rparam.speed);
                effector.Rotate(rparam.degree, rparam.way, rparam.speed);
                break;

            case "transition":
                var tparam = JsonConvert.DeserializeObject <Transition>(task.parameters);
                Console.WriteLine(" [i] make transition with param [xdes,ydes: ({0},{1}), speed: {2}, xpos,ypos: ({3},{4})]",
                                  tparam.xdes, tparam.ydes, tparam.speed, tparam.xpos, tparam.ypos);
                effector.Transition(tparam.xdes, tparam.ydes, tparam.speed, tparam.xpos, tparam.ypos);
                break;

            default:
                Console.WriteLine(" [!] not supported effect {0}, fallback to appear with 3 seconds",
                                  task.effect_name);
                goto case "appear";
            }
        }
Exemplo n.º 2
0
        static void TestEncode()
        {
            List <Effector> effectors = new List <Effector>();

            for (int i = 0; i < 5; i++)
            {
                var e = new Effector(23.98, new Size(800, 600));
                e.Initialize("white");

                // test effects
                e.Earthquake(20, 2, 2);
                e.Shake(2, 1, 3);
                e.Rotate(90, false, 2);
                e.FullRotate(15, false, 2);
                e.Transition(400, 400, 5, 0, 0);

                effectors.Add(e);
            }

            var a = new Encoder(effectors.ToArray());

            a.SequentialMerge();
            a.Encode("mp4");
        }