locked
How to get following light effects shown on the pictures? RRS feed

  • Question

  • I know about pathgradientbrush and lineargradientbrush, but i have no idea how to get following effects.

    How?





    • Edited by Ziya Ceferov Saturday, November 29, 2014 11:45 AM
    Saturday, November 29, 2014 11:44 AM

Answers

  • refer to :

    Outline Text


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    • Marked as answer by Ziya Ceferov Sunday, November 30, 2014 8:49 AM
    Saturday, November 29, 2014 5:08 PM
  • I got it, here is a code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Drawing.Drawing2D;
    
    namespace _123
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                this.BackColor = Color.Black;
                this.Paint += Draw;
                Draw_Bitmap();
            }
    
            private void Draw(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawImage(bitmap1, 0, 0);
            }
    
            Bitmap bitmap1 = new Bitmap(1000, 1000);
    
            private void Draw_Bitmap()
            {
                Graphics g = Graphics.FromImage(bitmap1);
                GraphicsPath path = new GraphicsPath();
    
                string stringText = "Sample Text";
                FontFamily family = new FontFamily("Arial");
                int fontStyle = (int)FontStyle.Regular;
                int emSize = 100;
                Point origin = new Point(20, 20);
                StringFormat format = StringFormat.GenericDefault;
    
                path.AddString(stringText,
                    family,
                    fontStyle,
                    emSize,
                    origin,
                    format);
    
                g.SmoothingMode = SmoothingMode.AntiAlias;
                int alpha = 1;
                for (int path_width = 20; path_width >= 2; path_width--)
                {
                    path.Reset();
    
                    path.AddString(stringText,
                    family,
                    fontStyle,
                    emSize,
                    origin,
                    format);
                    path.AddLines(new Point[] { new Point(50, 200), new Point(120, 200), new Point(85, 320), new Point(50, 200) });
    
                    path.CloseAllFigures();
    
                    g.DrawPath(new Pen(Color.Black, path_width), path);
                    g.DrawPath(new Pen(Color.FromArgb(alpha += 12, 255, 255, 255), path_width), path);
                }
            }
        }
    }
    

    Thank you.

    • Edited by Ziya Ceferov Sunday, November 30, 2014 8:49 AM
    • Marked as answer by Ziya Ceferov Sunday, November 30, 2014 8:49 AM
    Sunday, November 30, 2014 8:48 AM

All replies

  • refer to :

    Outline Text


    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    • Marked as answer by Ziya Ceferov Sunday, November 30, 2014 8:49 AM
    Saturday, November 29, 2014 5:08 PM
  • I can outline using Pen.Width and GraphicsPath.Widen.

    Is it the only way?

    It can not be used to outline a circle by keeping its shape.

    My goal is to outline a circle, but this way doesn't keep its shape.

    I know about pathgradientbrush for circle, but i wanna use it not only for circle and shape loses its form if to use Pen.Width.

    Is it the only way?


    • Edited by Ziya Ceferov Saturday, November 29, 2014 5:59 PM
    Saturday, November 29, 2014 5:51 PM
  • I got it, here is a code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Drawing.Drawing2D;
    
    namespace _123
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                this.BackColor = Color.Black;
                this.Paint += Draw;
                Draw_Bitmap();
            }
    
            private void Draw(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawImage(bitmap1, 0, 0);
            }
    
            Bitmap bitmap1 = new Bitmap(1000, 1000);
    
            private void Draw_Bitmap()
            {
                Graphics g = Graphics.FromImage(bitmap1);
                GraphicsPath path = new GraphicsPath();
    
                string stringText = "Sample Text";
                FontFamily family = new FontFamily("Arial");
                int fontStyle = (int)FontStyle.Regular;
                int emSize = 100;
                Point origin = new Point(20, 20);
                StringFormat format = StringFormat.GenericDefault;
    
                path.AddString(stringText,
                    family,
                    fontStyle,
                    emSize,
                    origin,
                    format);
    
                g.SmoothingMode = SmoothingMode.AntiAlias;
                int alpha = 1;
                for (int path_width = 20; path_width >= 2; path_width--)
                {
                    path.Reset();
    
                    path.AddString(stringText,
                    family,
                    fontStyle,
                    emSize,
                    origin,
                    format);
                    path.AddLines(new Point[] { new Point(50, 200), new Point(120, 200), new Point(85, 320), new Point(50, 200) });
    
                    path.CloseAllFigures();
    
                    g.DrawPath(new Pen(Color.Black, path_width), path);
                    g.DrawPath(new Pen(Color.FromArgb(alpha += 12, 255, 255, 255), path_width), path);
                }
            }
        }
    }
    

    Thank you.

    • Edited by Ziya Ceferov Sunday, November 30, 2014 8:49 AM
    • Marked as answer by Ziya Ceferov Sunday, November 30, 2014 8:49 AM
    Sunday, November 30, 2014 8:48 AM
  • Hi,

    the last picture seems to be a line drawn with a custom pen, the others are somewhat like colored shadows.

    My suggestion: use wpf - you can use the drop shadow effect. A more general solution would be to use an override glow filter / "glow halo" effect.

    Regards,

      Thorsten

    Sunday, November 30, 2014 12:02 PM