예제 #1
0
        void SetEffectProperty(IFx fx, string classname, string property, JsonValue jsonv)
        {
            var pi = fx.GetType().GetRuntimeProperty(property);

            if (null == pi)
            {
                throw new JsonEffectParameterUnknownException(classname, jsonv);
            }
            // check for configurable
            var ca = pi.GetCustomAttribute <ConfigurableAttribute>(true);

            if (null == ca)
            {
                throw new JsonEffectParameterNotConfigurableException(classname, jsonv);
            }
            // a JSON object as the value is always some complex solution, probably a control
            if (JsonValueKind.Object == jsonv.ValueKind)
            {
                var vctl = jsonv.AsObject()["Control"];
                if (!Program.Controls.TryGetValue(vctl.AsString(), out IControlVariable ctl))
                {
                    throw new JsonEffectParameterControlReferenceUnknown(vctl);
                }
                // grab the current value
                ca.SetObjectProperty(fx, pi, ctl.Value, false);
                // set up for change triggers
                ctl.ValueChanged += (s, e) => ca.SetObjectProperty(fx, pi, ctl.Value, false);
            }
            else
            {
                // the property determines JSON interpretation
                switch (pi.PropertyType.Name)
                {
                //case "String": -- lolwut?
                //	break;
                case "Int32":
                case "Int64":
                case "Double":
                case "Single":
                    // test limits
                    try {
                        ca.SetObjectProperty(fx, pi, jsonv.AsNumber(), true);
                    }
                    catch (Exception ex) {
                        throw new JsonEffectParameterValueOutOfRangeException(classname, jsonv, ex.Message);
                    }
                    break;

                case "Color":
                    // @todo: colour property parsing
                    break;
                }
            }
        }
예제 #2
0
        public SequenceParty()
        {
            Luminance  = AddLuminanceControl(x => { });
            Saturation = AddSaturationControl(x => { });

            // comets!
            mGlimRedGun  = new GlimDescriptor("Red", "GlimSwarm-103", 150, Color.Red);
            mGlimBlueGun = new GlimDescriptor("Blue", "GlimSwarm-104", 100, Color.Blue);
            mGlimStars   = new SequenceDeviceBasic("Stars", "GlimSwarm-102", 150);
            mFxBarrel    = new FxComet {
                BaseColor = Color.FromArgb(0xff, 0, 0xff), PixelCount = 50
            };
            mFxCannonTwinkle = new FxStarlightTwinkle {
                BaseColor       = Color.FromArgb(0xff, 0, 0xff),
                SpeedFactor     = 15.0,
                LuminanceMinima = 0.2,
                LuminanceMaxima = 0.8
            };

            mPixelMapStars = new GlimPixelMap.Factory {
                mGlimStars
            }.Compile();
            mPixelMapBarrel = new GlimPixelMap.Factory {
                { mGlimRedGun, 100, 50 }
            }.Compile();
            mPixelMapPerimeter = new GlimPixelMap.Factory {
                { mGlimRedGun, 0, 100 }, { mGlimBlueGun, 100, -100 }
            }.Compile();

            mFxPerimeterRainbow = new FxScale(new FxRainbow());
            mFxStarlight        = new FxScale(new FxStarlightTwinkle {
                BaseColor = Color.Yellow
            })
            {
                Saturation = 0.3
            };
        }
예제 #3
0
 public GreedyBestFirstSearch(IProblem p, IFx<Node> heuristicFx )
     : base(p, new PyPriorityQueue<Node>(heuristicFx))
 {
 }
예제 #4
0
 public SimulatedAnnealing(IProblem problem, IFx <int> schedule)
 {
     _myProblem  = problem;
     _mySchedule = schedule;
 }
예제 #5
0
 public PyPriorityQueue(IFx <T> fx)
 {
     _func = fx;
 }
예제 #6
0
 /// <summary>
 /// Sec. 3.5.2
 /// The most widely known form of best-first is called A* (pronounced "A-star")
 /// </summary>
 /// <param name="problem"></param>
 /// <param name="hOfn">
 /// the cost to get from the node to the goal;
 /// is the estimated cost of the cheapest path from (n) to the goal
 /// </param>
 public AstarSearch(IProblem problem, IFx <Node> hOfn)
     : base(problem, new PyPriorityQueue <Node>(gOfn + hOfn))
 {
 }
예제 #7
0
 public HillClimbing(IProblem problem, IFx <Node> calcValue)
 {
     _myProblem = problem;
     _calcValue = calcValue;
 }
예제 #8
0
파일: FxScale.cs 프로젝트: Boomtime/glimmer
 public FxScale(IFx src) : this()
 {
     mSrc = src;
 }
예제 #9
0
파일: FxScale.cs 프로젝트: Boomtime/glimmer
 public FxScale()
 {
     mSrc = new FxSolid {
         Colour = Color.White
     };
 }
예제 #10
0
파일: FxScale.cs 프로젝트: Boomtime/glimmer
 public void AddSource(IFx src)
 {
     mSrc = src;
 }
예제 #11
0
 /// <summary>
 /// Sec. 3.5.2
 /// The most widely known form of best-first is called A* (pronounced "A-star")
 /// </summary>
 /// <param name="problem"></param>
 /// <param name="hOfn">
 /// the cost to get from the node to the goal;
 /// is the estimated cost of the cheapest path from (n) to the goal
 /// </param>
 public AstarSearch(IProblem problem, IFx<Node> hOfn)
     : base(problem, new PyPriorityQueue<Node>(gOfn + hOfn))
 {
 }
예제 #12
0
 public GreedyBestFirstSearch(IProblem p, IFx <Node> heuristicFx) : base(p, new PyPriorityQueue <Node>(heuristicFx))
 {
 }