I'm trying to draw spherical pieces for a game, in WPF. Pieces are drawns as Elipses with RadialGradientBrushs. As you can see below, my black pieces look fantastic, but it is hard to get the white ones having any depth without making them look grey.
I'm currently using:
private readonly Brush _whitePieceBrush = new RadialGradientBrush(Colors.Snow, Colors.Ivory);
private readonly Brush _blackPieceBrush = new RadialGradientBrush(Colors.DarkGray, Colors.Black);
...
using (DrawingContext dc = _piecesVisual.RenderOpen())
{
....
Brush brush = piece.Value.IsBlack ? _blackPieceBrush : _whitePieceBrush;
var pen = new Pen(new SolidColorBrush(Colors.Black), 0.5);
dc.DrawEllipse(brush, pen, new Point(posX, posY), 15, 15);
...
}
The black circles around the white pieces don't help, but with out them, it looks even worse. (If I can find a good way to draw them that looks better, I'll be removing it)
I tried:
private readonly Brush _whitePieceBrush = new RadialGradientBrush()
{
GradientStops = new GradientStopCollection
{
new GradientStop(Colors.WhiteSmoke,0.3),
new GradientStop(Colors.LightGray, 1.0),
}
};
private readonly Brush _whitePieceBorder = new SolidColorBrush(Colors.Silver);
Taking Clemens' advice and having them off center: With them a bit off center: I think this helps the black more than the white, but still and improvement
private static readonly Point _lightSource = new Point(0.3, 0.35);
private readonly Brush _blackPieceBrush = new RadialGradientBrush(Colors.DarkGray, Colors.Black)
{
GradientOrigin = _lightSource
};
private readonly Brush _blackPieceBorder = new SolidColorBrush(Colors.Black);
private readonly Brush _whitePieceBrush = new RadialGradientBrush()
{
GradientOrigin = _lightSource,
GradientStops = new GradientStopCollection
{
new GradientStop(Colors.WhiteSmoke,0.3),
new GradientStop(Colors.LightGray, 1.0),
}
};
private readonly Brush _whitePieceBorder = new SolidColorBrush(Colors.Silver);