private void draw(int totKg) { var fg = display.ScriptForegroundColor; var bg = display.ScriptBackgroundColor; var c*k = Color.White.Alpha(0.07f); var cWarn = Color.DarkOrange.Alpha(0.80f); var cBad = Color.DarkRed.Alpha(0.80f); var showWarn = totKg >= wgt1; var showBad = totKg >= wgt2; // BG var sprite = new MySprite { Type = SpriteType.TEXTURE, Data = "Grid", Position = viewport.Center, Size = display.TextureSize * 2, Color = Color.RoyalBlue, Alignment = TextAlignment.CENTER }; frame.Add(sprite); var sb = new StringBuilder(); sb.AppendLine(" DNGR WGT " + KgToString(wgt1)); sb.AppendLine("FATAL WGT " + KgToString(wgt2)); sb.AppendLine("~ ~ ~ ~ ~ ~"); sb.AppendLine("CARGO WGT " + KgToString(totKg)); var textPosition = new Vector2(viewport.Width / 2, 0) + viewport.Position; var textColor = fg; if (showWarn) { textColor = cWarn; } if (showBad) { textColor = cBad; } // Text sprite = new MySprite() { Type = SpriteType.TEXT, Data = sb.ToString(), Position = textPosition, RotationOrScale = 0.9f, // 90% font size Color = textColor, Alignment = TextAlignment.CENTER, FontId = "White" }; frame.Add(sprite); // Start positions/proportions on the bar // var okP = 0.0f; // var badP = 0.9f; var totBarKg = (wgt2 + wgt2 / 9f); var warnP = ((float)wgt1 / totBarKg); var filledP = (float)totKg / totBarKg; var barHeight = viewport.Height / 3f; var barWidth = viewport.Width * 0.9f; var barPosition = viewport.Position + new Vector2( (viewport.Width - barWidth) / 2f, viewport.Height - barHeight / 2f - barHeight / 4f); var okWidth = barWidth * warnP; var badWidth = barWidth * 0.1f; var warnWidth = barWidth - okWidth - badWidth; var rulerHeight = barHeight * 0.15f; var nonRulerHeight = barHeight - rulerHeight; var filledWidth = barWidth * filledP; var emptyWidth = barWidth - filledWidth; // Ruler var rulerPosition = barPosition; drawBar( rulerPosition, new Vector2(okWidth, rulerHeight), c*k ); drawBar( rulerPosition + new Vector2(okWidth, 0), new Vector2(warnWidth, rulerHeight), cWarn ); drawBar( rulerPosition + new Vector2(okWidth + warnWidth, 0), new Vector2(badWidth, rulerHeight), cBad ); // Weight Bar var fillPosition = barPosition + new Vector2(0, rulerHeight / 2f); var cx = (int)Math.Ceiling(fillPosition.X); var cy = (int)Math.Ceiling(fillPosition.Y); var cw = (int)Math.Ceiling(filledWidth); var ch = (int)Math.Ceiling(nonRulerHeight); var clipRect = new Rectangle(cx, cy, cw, ch); frame.Add(MySprite.CreateClipRect(clipRect)); drawBar( fillPosition, new Vector2(okWidth, nonRulerHeight), c*k ); drawBar( fillPosition + new Vector2(okWidth, 0), new Vector2(warnWidth, nonRulerHeight), cWarn ); drawBar( fillPosition + new Vector2(okWidth + warnWidth, 0), new Vector2(badWidth, nonRulerHeight), cBad ); frame.Add(MySprite.CreateClearClipRect()); }