我有一个光泽方法,我正在尝试获得类似倒半月的效果。在下面的代码中,我想删除该椭圆的下半部分上方,然后绘制它。有谁知道我如何开始这样做?
PS。光泽也变得太白。我试过弄乱阿尔法但无济于事,有人知道有什么技巧可以让光泽更微妙吗? 谢谢 /// <summary>
/// Applies gloss to clock
/// </summary>
/// <param name="e"></param>
private void DrawGloss(PaintEventArgs e)
{
Graphics g = e.Graphics;
float x = ((float)_CenterX / 1.1F) / _PI;
float y = ((float)_CenterY / 1.2F) / _PI;
float width = ((this.ClientSize.Width / 2)) + _hourLength;
float height = ((this.ClientSize.Height / 2)) + _hourLength;
RectangleF glossRect = new RectangleF(
x + (float)(width * 0.10),
y + (float)(height * 0.07),
(float)(width * .8),
(float)(height * 0.4));
LinearGradientBrush gradientBrush =
new LinearGradientBrush(glossRect,
Color.FromArgb((int)50, Color.Transparent),
glossColor,
LinearGradientMode.BackwardDiagonal);
g.FillEllipse(gradientBrush, glossRect);
}
最佳答案
FillPie 可以给你正好半个圆。否则,您必须使用 FillClosedCurve 或 FillPath 来获得略小于半个圆,或者在中间稍小的位图上绘制半圆,然后使用 DrawImage 将其复制回主位图上。
为了获得更微妙的光泽效果,我认为您只需将 LinearGradientBrush 代码更改为:
LinearGradientBrush gradientBrush =
new LinearGradientBrush(glossRect,
Color.Transparent,
Color.FromArgb((int)50, glossColor),
LinearGradientMode.BackwardDiagonal);
您的原始渐变是从完全透明到全光泽颜色。
关于C# GDI+ - 在光泽方法上删除椭圆下半部分上方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1429181/