14,218,748 members
Rate this:
See more:
Hello Everyone,

I am looking for the small snippet c# code to draw a lightning bolt symbol.
To give you an idea, I am looking for the code the generate this kind of image: lightning bolt.

Even a non filled in lightning bolt symbol would be great.

Thank you very much in advance.

Best regards.
MiQi

What I have tried:

I have created an image (png) but the shape resize is not really nice when I draw it on top of the picture box.

Using drawline, ... would produce a better result.
Posted
Updated 8-May-18 4:40am
v2
#realJSOP 8-May-18 10:09am

What is a thunderlight" symbol? Do you by chance mean "lightning bolt"?
SuperMiQi 8-May-18 10:14am

That is correct, I have changed the naming. Thank you.

Rate this:

## Solution 1

Seriously? You want someone to generate coordinates for 7 points for you?

Grab a piece of paper, a pencil, and a ruler. Draw your lightning shape on the paper. Measure the width of the shape. The top left is going to be 0,0. The top right is going to be 0,1. For any points between, they are going to be a percentage of 1. If the point you need is half way between 0 and 1, that point, at the top of the shape, is going to be 0,0.5.

Do the same for the height. Half way down the shape, on the far left edge, is going to be 0.5,0.

But, I hear you asking "why values betwen 0 and 1?" That's because you can scale your image to any size just by multiplying the width and height of the image you want by the values you generated for each point to get the scaled point.
SuperMiQi 8-May-18 10:18am

Thank you.
I will manage it by myselft from your great inputs.
SuperMiQi 8-May-18 10:21am

I thought there was a magic way to create it from the pasting an image on top with transparency. But maybe is the drawing method the fastest way.
Maciej Los 8-May-18 10:52am

I really do like such of "hints"!
5ed!
Rate this:

## Solution 2

Like this one 🗲 or this one 🗱 or 🌩 ... these are characters in the Windows Webdings font: [^]. You can easily scale these up, and take a screen shot, and then create ... whatever.

Or, you can take a Label Control whose text is the symbol, set its 'BackColor to 'Transparent, and then set its 'Parent to the 'PictureBox, then set its 'Location in 'PictureBox co-ordinates:

in the designer:
```// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Webdings", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(2)));
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(121, 229);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(93, 65);
this.label1.TabIndex = 10;
this.label1.Text = "~";```
```label1.Parent = pictureBox1;
label1.Location = new Point(20,20);```
v2
Maciej Los 8-May-18 10:54am

Pretty interesting idea, Bill!
SuperMiQi 8-May-18 10:54am

Thank you so much.
I was pretty sure something direct should exist.
That is exactly what I am looking for.
BillWoodruff 8-May-18 11:12am

@SuperMiQi You're welcome. I've added an example of how you can get a Label with this symbol to appear over the PictureBox image with a transparent background.
SuperMiQi 8-May-18 11:17am

Thank you soooooo much Bill. You are bringing nice tips.