/// <summary> /// Given some offset rectangle, and some logical position, draw a solid color rectangle and text over it. /// </summary> public static void DrawTextOnRectangle(BaseGameModel model, Position logPosOffsetRect, Position logPosRect, SolidBrush sbBaseRect, SolidBrush sbText, Graphics g, Font f, String text) { logPosRect = logPosRect.AddPositionUpperLeft(logPosOffsetRect); Position disPosRect = model.Camera.MapLogicalToDisplay(logPosRect, true); Drawing2D.DrawRect(g, sbBaseRect, disPosRect); Position disPosText = model.Camera.BottomLeftAlignTextWithinRect(logPosRect, text, f, g, true); g.DrawString(text, f, sbText, (Single)disPosText.UpperLeftX, (Single)disPosText.UpperLeftY); }
/// <summary> /// Draws a rectangle with a border. Basically draws a larger rectangle with the border color, and then draws a small /// rectangle inside with the fill color. /// Returns the display position for the inner rectangle. /// If the fill color is semi-transparent, realize that due to the implementation of this method, the border color will appear through /// the fill color. /// </summary> public static void FillRectWithBorder(BaseGameModel model, Graphics g, Position rectDisplay, Brush borderColor, Brush fillColor, Double borderSizeLogical, Boolean ignoreCameraPos, out Position rectInnerDisplay) { Position p = rectDisplay; Drawing2D.DrawRect(g, borderColor, p); rectInnerDisplay = new Position(p); Double scale = model.Camera.GetScale(ignoreCameraPos); rectInnerDisplay.TransformByPixels(-borderSizeLogical * scale); Drawing2D.DrawRect(g, fillColor, rectInnerDisplay); }
/// <summary> /// Draws a solid/filled rectangle. Maps this rectangle to the display window based on the camera. /// </summary> public static void DrawRect(BaseGameModel model, Graphics g, Brush b, Position rect) { Position rectAdjusted = model.Camera.MapLogicalToDisplay(rect, true); Drawing2D.DrawRect(g, b, rectAdjusted); }