C# GDI+ - 在光泽方法上删除椭圆下半部分上方

发布于 2024-08-04 18:34:52 字数 1145 浏览 2 评论 0原文

我有一个光泽方法,我正在尝试获得类似倒半月的效果。在下面的代码中,我想删除该椭圆的下半部分上方,然后绘制它。有谁知道我如何开始这样做?

附言。光泽也变得太白。我试过弄乱阿尔法但无济于事,有人知道有什么技巧可以让光泽更微妙吗? 谢谢

  /// <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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏辞 2024-08-11 18:34:53

FillPie 可以给你正好半个圆。否则,您必须使用 FillClosedCurve 或 FillPath 来获得略小于半个圆,或者在中间稍小的位图上绘制半圆,然后使用 DrawImage 将其复制回主位图上。

为了获得更微妙的光泽效果,我认为您只需将 LinearGradientBrush 代码更改为:

LinearGradientBrush gradientBrush =                
    new LinearGradientBrush(glossRect,                
    Color.Transparent,                
    Color.FromArgb((int)50, glossColor),                
    LinearGradientMode.BackwardDiagonal);

您的原始渐变从完全透明变为全光泽颜色。

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:

LinearGradientBrush gradientBrush =                
    new LinearGradientBrush(glossRect,                
    Color.Transparent,                
    Color.FromArgb((int)50, glossColor),                
    LinearGradientMode.BackwardDiagonal);

Your original gradient was going from fully transparent to full glossColor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文