private int CountToY(decimal count) { if (highCountRange == 0) { return(0); } return((int)Mathm.Map(count, lowCountRange, highCountRange, bottomMargin, height - 20)); }
private int ValueToX(decimal value) { if (highValueRange == 0) { return(0); } return((int)Mathm.Map(value, lowValueRange, highValueRange, leftMargin, width - rightMargin)); }
private void DrawYLabels(int count, int size, int offset) { for (int i = height; i >= offset; i -= (height / count)) { buffer.Graphics.DrawLine(Pens.Gray, new Point(size - 3, i - offset), new Point(size, i - offset)); decimal percent = Mathm.Normalize(height - i, 0, height); decimal v = Mathm.Sweep(percent, lowCountRange, highCountRange); buffer.Graphics.DrawString(v.ToString("###,##0"), new Font("Cambria", 8), Brushes.Gray, new PointF(3, i - offset - 6)); } }
private void DrawXLabels(int count, int size, int offset) { for (int i = offset; i < width - rightMargin; i += (width / count)) { buffer.Graphics.DrawLine(Pens.Gray, new Point(i, height - size), new Point(i, height + 3 - size)); decimal percent = Mathm.Normalize(i, offset, width); decimal v = Mathm.Sweep(percent, lowValueRange, highValueRange); buffer.Graphics.DrawString(v.ToString("C"), new Font("Cambria", 8), Brushes.Gray, new PointF(i - 12, height - 12)); } buffer.Graphics.DrawString(MarketValue.ToString("C"), new Font("Cambria", 8), Brushes.Gray, new PointF(50, 100)); buffer.Graphics.DrawLine(Pens.Gray, new Point((width / 2) + leftMargin, height - bottomMargin), new Point((width / 2) + leftMargin, 0)); }
private static Vector2d CalcVelocity2d(double x, double y, double g, double v, bool useUpper) { var m = useUpper ? 1 : -1; var minV = Math.Sqrt(g * (y + Mathm.Hypot(x, y))) * 1.0001; v.MaxWith(minV); var c = g * x / v / v; var sqrt = Math.Sqrt(1 - c * c - 2 * g * y / v / v); var a = Math.Atan((1 + m * sqrt) / c); var vx = v * Math.Cos(a); //backwards. var vy = v * Math.Sin(a); return(new Vector2d(vx, vy)); }
public async Task RollAsync(EventContext e) { string rollCalc = ""; string amount = ""; int rollAmount = 0; if (e.arguments != "") { amount = e.arguments.Split(' ')[0]; if (amount.Split('d').Length > 1) { for (int i = 0; i < int.Parse(amount.Split('d')[0]); i++) { int num = Mathm.Roll(int.Parse(amount.Split('d')[1]), 0); rollAmount += num; rollCalc += num + " + "; } rollCalc = rollCalc.Remove(rollCalc.Length - 3); } else { try { rollAmount = Mathm.Roll(int.Parse(amount), 0); } catch { rollAmount = Mathm.Roll(); } } } else { rollAmount = Mathm.Roll(); } if (rollAmount == 1) { await AchievementManager.Instance.GetContainerById("badluck").CheckAsync(new Accounts.Achievements.Objects.BasePacket() { discordUser = e.Author, discordChannel = e.Channel }); } await e.Channel.SendMessage(Locale.GetEntity(e.Guild.Id.ToDbLong()).GetString(Locale.RollResult, new object[] { e.Author.Username, rollAmount }) + (rollCalc != "" ? " (" + rollCalc + ")" : "")); }
/// <summary> /// Get this boolean as a sign. /// 1 if true, -1 otherwise. /// </summary> /// <param name="_bool">Boolean to get sign from.</param> /// <returns>Returns this boolean sign as 1 or -1.</returns> public static int Sign(this bool _bool) => Mathm.Sign(_bool);
private bool DrawPair(decimal value, decimal count, decimal value2, decimal count2) { int x = (int)Mathm.Map(value, lowValueRange, highValueRange, leftMargin, width - rightMargin) + (leftMargin / 2); int y = height - (int)Mathm.Map(count, lowCountRange, highCountRange, bottomMargin, height - 20); int x2 = (int)Mathm.Map(value2, lowValueRange, highValueRange, leftMargin, width - rightMargin) + (leftMargin / 2); int y2 = height - (int)Mathm.Map(count2, lowCountRange, highCountRange, bottomMargin, height - 20); if (x2 < (width / 2) + leftMargin) //left side { if (y2 < 0) { //g.FillRectangle(new SolidBrush(Color.FromArgb(127, 50, 50, 50)), new Rectangle(xOffset, 0, x-xOffset, (height - 20))); buffer.Graphics.FillRectangle(Brushes.DarkGreen, new Rectangle(leftMargin, 0, x - leftMargin, (height - bottomMargin))); buffer.Graphics.DrawLine(new Pen(Color.LightGreen, 2), new Point(x, y), new Point(x, 0)); return(false); } else if (x2 < leftMargin) { return(false); } else { if (count2 - count > 40 && y2 - 53 > 0) { buffer.Graphics.DrawString(value.ToString("C"), new Font("Cambria", 8), Brushes.Gray, new PointF(x + 30, y2 - 43)); buffer.Graphics.DrawLine(Pens.Black, new Point(x, y2), new Point(x + 30, y2 - 30)); } buffer.Graphics.FillRectangle(Brushes.DarkGreen, new Rectangle(x2, y2, x - x2, (height - y2) - bottomMargin)); buffer.Graphics.DrawLine(new Pen(Color.LightGreen, 2), new Point(x, y), new Point(x, y2)); buffer.Graphics.DrawLine(new Pen(Color.LightGreen, 2), new Point(x, y2), new Point(x2, y2)); } } else { if (y2 < 0) { //g.FillRectangle(new SolidBrush(Color.FromArgb(127, 50, 50, 50)), new Rectangle(xOffset, 0, x-xOffset, (height - 20))); buffer.Graphics.FillRectangle(Brushes.Maroon, new Rectangle(x - 1, y2, width - x2, height - y2 - bottomMargin)); buffer.Graphics.DrawLine(new Pen(Color.Salmon, 2), new Point(x, y), new Point(x, 0)); return(false); } else if (x2 > width - rightMargin) { return(false); } else { if (count2 - count > 70 && y2 - 53 > 0) { buffer.Graphics.DrawString(value2.ToString("C"), new Font("Cambria", 8), Brushes.Gray, new PointF(x - (value2.ToString("C").Length * 10), y2 - 43)); buffer.Graphics.DrawLine(Pens.Black, new Point(x, y2), new Point(x - 30, y2 - 30)); } buffer.Graphics.FillRectangle(Brushes.Maroon, new Rectangle(x, y2, x2 - x, height - y2 - bottomMargin)); buffer.Graphics.DrawLine(new Pen(Color.Salmon, 2), new Point(x, y), new Point(x, y2)); buffer.Graphics.DrawLine(new Pen(Color.Salmon, 2), new Point(x, y2), new Point(x2, y2)); } } return(true); }