public static void FillSquare(Graphics oGraphics, Brush oBrush, float fXCenter, float fYCenter, float fHalfWidth) { Debug.Assert(oGraphics != null); Debug.Assert(fHalfWidth >= 0f); RectangleF oRectangle = GraphicsUtil.SquareFromCenterAndHalfWidth(fXCenter, fYCenter, fHalfWidth); Rectangle rect = GraphicsUtil.RectangleFToRectangle(oRectangle, 1); oGraphics.FillRectangle(oBrush, rect); }
public static void FillSquare3D(Graphics oGraphics, Color oColor, float fXCenter, float fYCenter, float fHalfWidth) { Debug.Assert(oGraphics != null); Debug.Assert(fHalfWidth >= 0f); GraphicsPath graphicsPath = new GraphicsPath(); RectangleF rect = GraphicsUtil.SquareFromCenterAndHalfWidth(fXCenter, fYCenter, fHalfWidth); graphicsPath.AddRectangle(rect); PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath); pathGradientBrush.CenterPoint = new PointF(fXCenter, fYCenter); pathGradientBrush.CenterColor = Color.White; pathGradientBrush.SurroundColors = new Color[] { oColor }; oGraphics.FillRectangle(pathGradientBrush, rect); pathGradientBrush.Dispose(); graphicsPath.Dispose(); }
public static void FillCircle3D(Graphics oGraphics, Color oColor, float fXCenter, float fYCenter, float fRadius) { Debug.Assert(oGraphics != null); Debug.Assert(fRadius >= 0f); GraphicsPath graphicsPath = new GraphicsPath(); RectangleF rect = GraphicsUtil.SquareFromCenterAndHalfWidth(fXCenter, fYCenter, fRadius); graphicsPath.AddEllipse(rect); PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath); pathGradientBrush.CenterPoint = new PointF(rect.Left + rect.Width / 3f, rect.Top + rect.Height / 3f); pathGradientBrush.CenterColor = Color.White; pathGradientBrush.SurroundColors = new Color[] { oColor }; oGraphics.FillRectangle(pathGradientBrush, rect); pathGradientBrush.Dispose(); graphicsPath.Dispose(); }