public JsMathConstructor(IGlobal global) { Global = global; var random = new Random(); #region Functions this["abs"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Abs(d)))); this["acos"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Acos(d)))); this["asin"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Asin(d)))); this["atan"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Atan(d)))); this["atan2"] = new ClrFunction(new Func<double, double, JsNumber>((y, x) => Global.NumberClass.New(Math.Atan2(y, x)))); this["ceil"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Ceiling(d)))); this["cos"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Cos(d)))); this["exp"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Exp(d)))); this["floor"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Floor(d)))); this["log"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Log(d)))); this["max"] = new ClrFunction(new Func<double, double, JsNumber>((a, b) => Global.NumberClass.New(Math.Max(a, b)))); this["min"] = new ClrFunction(new Func<double, double, JsNumber>((a, b) => Global.NumberClass.New(Math.Min(a, b)))); this["pow"] = new ClrFunction(new Func<double, double, JsNumber>((a, b) => Global.NumberClass.New(Math.Pow(a, b)))); this["random"] = global.FunctionClass.New(new Func<double>(random.NextDouble)); this["round"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Round(d)))); this["sin"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Sin(d)))); this["sqrt"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Sqrt(d)))); this["tan"] = new ClrFunction(new Func<double, JsNumber>(d => Global.NumberClass.New(Math.Tan(d)))); #endregion this["E"] = global.NumberClass.New(Math.E); this["LN2"] = global.NumberClass.New(Math.Log(2)); this["LN10"] = global.NumberClass.New(Math.Log(10)); this["LOG2E"] = global.NumberClass.New(Math.Log(Math.E, 2)); this["PI"] = global.NumberClass.New(Math.PI); this["SQRT1_2"] = global.NumberClass.New(Math.Sqrt(0.5)); this["SQRT2"] = global.NumberClass.New(Math.Sqrt(2)); }
public JsMathConstructor(IGlobal global) { Global = global; var random = new Random(); #region Functions this["abs"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Abs(d)))); this["acos"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Acos(d)))); this["asin"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Asin(d)))); this["atan"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Atan(d)))); this["atan2"] = new ClrFunction(new Func <double, double, JsNumber>((y, x) => Global.NumberClass.New(Math.Atan2(y, x)))); this["ceil"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Ceiling(d)))); this["cos"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Cos(d)))); this["exp"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Exp(d)))); this["floor"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Floor(d)))); this["log"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Log(d)))); this["max"] = new ClrFunction(new Func <double, double, JsNumber>((a, b) => Global.NumberClass.New(Math.Max(a, b)))); this["min"] = new ClrFunction(new Func <double, double, JsNumber>((a, b) => Global.NumberClass.New(Math.Min(a, b)))); this["pow"] = new ClrFunction(new Func <double, double, JsNumber>((a, b) => Global.NumberClass.New(Math.Pow(a, b)))); this["random"] = global.FunctionClass.New(new Func <double>(random.NextDouble)); this["round"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Round(d)))); this["sin"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Sin(d)))); this["sqrt"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Sqrt(d)))); this["tan"] = new ClrFunction(new Func <double, JsNumber>(d => Global.NumberClass.New(Math.Tan(d)))); #endregion this["E"] = global.NumberClass.New(Math.E); this["LN2"] = global.NumberClass.New(Math.Log(2)); this["LN10"] = global.NumberClass.New(Math.Log(10)); this["LOG2E"] = global.NumberClass.New(Math.Log(Math.E, 2)); this["PI"] = global.NumberClass.New(Math.PI); this["SQRT1_2"] = global.NumberClass.New(Math.Sqrt(0.5)); this["SQRT2"] = global.NumberClass.New(Math.Sqrt(2)); }
public JsFunction New(Delegate d) { JsFunction function = new ClrFunction(d, PrototypeProperty); function.PrototypeProperty = Global.ObjectClass.New(function); //function.Scope = new JsScope(PrototypeProperty); return(function); }
public JsFunction New(Delegate d) { JsFunction function = new ClrFunction(d); function.Prototype = Global.ObjectClass.New(function); function.Scope.Prototype = Prototype; return(function); }