C# GDI+ - 在光泽方法上删除椭圆下半部分上方
我有一个光泽方法,我正在尝试获得类似倒半月的效果。在下面的代码中,我想删除该椭圆的下半部分上方,然后绘制它。有谁知道我如何开始这样做?
附言。光泽也变得太白。我试过弄乱阿尔法但无济于事,有人知道有什么技巧可以让光泽更微妙吗? 谢谢
/// <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);
}
I have a gloss method and I'm trying to get a inverted half moon like effect. On the below code I'd like to remove just above bottom half of this ellipse and then draw it. Does anyone know how I might begin to do that?
PS. The gloss is also turning out too white. I've tried messing with the alpha to no avail, does anyone know any tricks to make the gloss more subtle?
Thank you
/// <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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FillPie 可以给你正好半个圆。否则,您必须使用 FillClosedCurve 或 FillPath 来获得略小于半个圆,或者在中间稍小的位图上绘制半圆,然后使用 DrawImage 将其复制回主位图上。
为了获得更微妙的光泽效果,我认为您只需将 LinearGradientBrush 代码更改为:
您的原始渐变从完全透明变为全光泽颜色。
FillPie could give you exactly half a circle. Otherwise you'd have to use FillClosedCurve or FillPath to get slightly less than half a circle, or draw a half-circle onto an intermediate, slightly smaller Bitmap and copy that back onto your main Bitmap with DrawImage.
For a more subtle gloss effect, I think you just need to change your LinearGradientBrush code to:
Your original gradient was going from fully transparent to full glossColor.