void draw() { if (index == 0) { reset(); } ctx.save(); var degree = degreesList[index]; var color = JsMath.floor(255 / degrees * index); ctx.strokeStyle = "rgb(" + color + ", " + color + ", " + color + ")"; ctx.lineWidth = spinnerData.size; ctx.beginPath(); var startAngle = JsMath.floor(360 / degrees * (degree)); var endAngle = JsMath.floor(360 / degrees * (degree + 1)) - 1; ctx.arc(spinnerData.x, spinnerData.y, spinnerData.size, (JsMath.PI / 180) * startAngle, (JsMath.PI / 180) * endAngle, false); ctx.stroke(); ctx.restore(); index++; if (index >= degrees) { index = 0; } }
private void makeAsynchronousRequest(JsString url, TranslationsFileLoaded fileLoaded) { XMLHttpRequest request = new XMLHttpRequest(); if (forceReload) { //just bust the cache for now url = url + "?rnd=" + JsMath.random(); } request.open("GET", url, true); request.onreadystatechange = delegate(DOMEvent evt) { if (request.readyState == 4 && request.status == 200) { parseResult(request.responseText); fileLoaded(); } else if (request.readyState >= 3 && request.status == 404) { HtmlContext.alert("Required Content " + url + " cannot be loaded."); throw new JsError("Cannot continue, missing required property file " + url); } }; request.send(""); }
/// <summary> /// use this to round to a percent (0 to 100) /// </summary> public static double RoundNumber(double num) { int dec = 2; double result = 100 * JsMath.Round(num * JsMath.Pow(10, dec)) / JsMath.Pow(10, dec); return(result); }
public virtual int GetHashCode() { if (__hashCode == null) { __hashCode = JsMath.random(); } return(__hashCode.Value); }
static void btn_onclick() { int num1 = parseInt(document.getElementById("textbox1").As <HtmlInput>().value); JsNumber num2 = parseInt(document.getElementById("textbox2").As <HtmlInput>().value); if (isNaN(num1) || isNaN(num2)) { alert("Please enter two valid numbers"); return; } var biggerNum = JsMath.max(num1, num2); alert("The bigger number is " + biggerNum); }
private double function(double x) { double y = Double.NaN; string expression = comboBox1.Text; expression = expression.Replace(String.Format("x"), x.ToString().Replace(String.Format(","), String.Format("."))); expression = expression.Replace(String.Format("e"), "2.71828182846"); //textBox4.AppendText(Round(x, 2) + "; " + Round(Convert.ToDouble(JsMath.Eval(expression)), 2) + "\r\n"); try { y = Convert.ToDouble(JsMath.Eval(expression)); } catch { } return(y); }
public static double Round(double value, MidpointRounding mode) { if (mode == MidpointRounding.AwayFromZero) { if (value < 0) { return(-JsMath.round(-value).As <double>()); } else { return(JsMath.round(value).As <double>()); } } else { throw new NotImplementedException(); } }
private void makeSynchronousRequest(JsString url) { XMLHttpRequest request = new XMLHttpRequest(); if (forceReload) { //just bust the cache for now url = url + "?rnd=" + JsMath.random(); } request.open("GET", url, false); request.send(""); if (request.status == 404) { HtmlContext.alert("Required Content " + url + " cannot be loaded."); throw new JsError("Cannot continue, missing required property file " + url); } parseResult(request.responseText); }
//this is the event handler for successful accelerometer readings public static void Suc(XdkAcceleration a) { //readings are from -1 to 1 (with 0 being equilibrium in a plane). Assumes holding in portrait mode //with screen pointed straight at your chest. //e.g. in the X plane -1 = tilted all the way left, 1 = tilted all the way right. //e.g. in the Y plane -1 = tilted all the way left, 1 = tilted all the way right. // HtmlElement.GetById("accel_x").innerHTML = "a.x = " + a.x + ", a.y = " + a.y; DoCanPhysics(a); //make sure the can isn't off the screen current_left = JsMath.Max(current_left, 0); current_top = JsMath.Max(current_top, -100); current_left = JsMath.Min(current_left, o_width - 100); current_top = JsMath.Min(current_top, o_height - 200); //visible width of label on can is 164 //total widht of label is 1074 if (labelleft <= -910) { labelleft = -373; } if (labelleft >= 0) { labelleft = -537; } //labelleft = labelleft % 537; //basically, we're going to slide and rotate the can around on the screen based on the physics //computed in the previous funciton. The animation calls are really fairly simple ... //need to check that container and label have been initialized in case deviceready happens before load JsCode(@"if (container != null) container.style.webkitTransform = ""translate("" + current_left + ""px, "" + current_top + ""px) rotate("" + canangle + ""deg) scale(.85, .85)"""); JsCode(@"if (label != null) label.style.webkitTransform = ""translate("" + labelleft + ""px, 0px)"""); //TODO if (container != null) container.style.webkitTransform = "translate(" + current_left + "px, " + current_top + "px) rotate(" + canangle + "deg) scale(.85, .85)"; //TODO if (label != null) label.style.webkitTransform = "translate(" + labelleft + "px, 0px)"; }
public static double Atan2(double y, double x) { return(JsMath.atan2(y, x).As <double>()); }
public static double Atan(double d) { return(JsMath.atan(d).As <double>()); }
public static double Acos(double d) { return(JsMath.acos(d).As <double>()); }
//public static sbyte Abs(sbyte value) //{ // return JsMath.abs(value).As<sbyte>(); //} public static float Abs(float value) { return(JsMath.abs(value).As <float>()); }
public static double Tan(double a) { return(JsMath.tan(a).As <double>()); }
//public static short Abs(short value) //{ // return JsMath.abs(value).As<short>(); //} public static int Abs(int value) { return(JsMath.abs(value).As <int>()); }
private static string S4() { JsNumber num = JsMath.floor((1 + JsMath.random()) * 0x10000); return(num.toString(16).substring(1)); }
public static float Min(float val1, float val2) { return(JsMath.min(val1, val2).As <long>()); }
public static double Round(double a) { return(JsMath.round(a).As <double>()); }
public static decimal Round(decimal d, int decimals) { var pow = JsMath.pow(10, decimals); return(JsMath.round(d * pow) / pow); }
public static decimal Round(decimal d) { return(JsMath.round(d).As <decimal>()); }
public static double Pow(double x, double y) { return(JsMath.pow(x, y).As <double>()); }
public static ulong Min(ulong val1, ulong val2) { return(JsMath.min((decimal)val1, (decimal)val2).As <ulong>()); }
public static decimal Ceiling(decimal d) { return(JsMath.ceil(d).As <decimal>()); }
public static double Sin(double a) { return(JsMath.sin(a).As <double>()); }
public static double Ceiling(double a) { return(JsMath.ceil(a).As <double>()); }
// private static double SplitFractionDouble(double* value) //{ //} public static double Sqrt(double d) { return(JsMath.sqrt(d).As <double>()); }
public static int Random(int max) { return(JsMath.random() * max); }
//public static ushort Min(ushort val1, ushort val2) //{ // return JsMath.min(val1, val2).As<ushort>(); //} public static uint Min(uint val1, uint val2) { return(JsMath.min((decimal)val1, (decimal)val2).As <uint>()); }
public static double Round(double value, int digits) { var pow = JsMath.pow(10, digits); return(JsMath.round(value * pow) / pow); }
public static long Abs(long value) { return(JsMath.abs((decimal)value).As <long>()); }