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; } } }
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 }; }
public GreedyBestFirstSearch(IProblem p, IFx<Node> heuristicFx ) : base(p, new PyPriorityQueue<Node>(heuristicFx)) { }
public SimulatedAnnealing(IProblem problem, IFx <int> schedule) { _myProblem = problem; _mySchedule = schedule; }
public PyPriorityQueue(IFx <T> fx) { _func = fx; }
/// <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)) { }
public HillClimbing(IProblem problem, IFx <Node> calcValue) { _myProblem = problem; _calcValue = calcValue; }
public FxScale(IFx src) : this() { mSrc = src; }
public FxScale() { mSrc = new FxSolid { Colour = Color.White }; }
public void AddSource(IFx src) { mSrc = src; }
/// <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)) { }
public GreedyBestFirstSearch(IProblem p, IFx <Node> heuristicFx) : base(p, new PyPriorityQueue <Node>(heuristicFx)) { }