I need help creating 2 polygons on a Splash

blueeyes53

Active member
Joined
May 2, 2006
Messages
25
Programming Experience
Beginner
:confused: Hi there,
I need to create 2 polygons on a splash screen. How do I calculate the size that I want to make them.

Top triangle: varies the green value from 0 to 255. The red and blue values are zero.

Lower triangle: was created by varying the blue value from 255 to 0. The red and green values are 0.

How to calculate the size that you want the triangles to be?

Thank you
Blueeyes:confused:
 
not sure what you are doing with the colors and what that has to do with the triangles. Acually Im not really sure what your asking at all. But if you want to know how to calculate the triangle in relation to the form then you use the form dimensions for example me.width, me.height. Is this on the track for the answer you want? Ask the question again and be more specific please as to what you want and what you are doing. I am pretty good with graphics sometimes and I think I might be able to help.
 
I still need help with it if you please

Hi there,
What is the code to calculate the 2 triangles in relation to the form.

I don't know how to use the me.width, me. height.

Thank you
H.Martinez
 
ok, you can use me.width and me.height as I mentioned if the form has no borders. But when you add borders it changes the height and width so it would be better to use me.clientsize.width and me.clientsize.height. This is my fault but all the same let me give you an example of how to use it.

clientsize is the size of the form inside of it's borders if it has any; if not it's the size of the form. Also, notice I convert points to Integer. When calculating points remember to do this, you never know where the point may end up with division and all.
me.clientsize.width is the length of the client area from left to right, Left being 0 and right being (y amount) however far the form is stretched.
height is the same except im sure you know it's up and down. 0 being top and x amount being bottom.

VB.NET:
[SIZE=2][COLOR=#0000ff]Protected [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnPaintBackground([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2]System.Windows.Forms.PaintEventArgs)
[/SIZE][SIZE=2][COLOR=#0000ff]     MyBase[/COLOR][/SIZE][SIZE=2].OnPaintBackground(e)[/SIZE]
[SIZE=2]'here i declare points for you to easily see what I am doing.  There are more efficient ways like putting points into arrays and what not.  This is just an aid to learn with.
[/SIZE][SIZE=2][COLOR=#0000ff]     Dim[/COLOR][/SIZE][SIZE=2] top [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point([/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Width / 2), 0)
[/SIZE][SIZE=2][COLOR=#0000ff]     Dim[/COLOR][/SIZE][SIZE=2] left [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point(0, [/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Height / 2))
[/SIZE][SIZE=2][COLOR=#0000ff]     Dim[/COLOR][/SIZE][SIZE=2] bottom [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point([/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Width / 2),[/SIZE][SIZE=2][COLOR=#0000ff]  Me[/COLOR][/SIZE][SIZE=2].ClientSize.Height)
[/SIZE][SIZE=2][COLOR=#0000ff]     Dim[/COLOR][/SIZE][SIZE=2] right [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Width, [/SIZE][SIZE=2][COLOR=#0000ff]CInt[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Height / 2))
     e.Graphics.DrawLine(Pens.Black, top, left)
     e.Graphics.DrawLine(Pens.Black, left, bottom)
     e.Graphics.DrawLine(Pens.Black, bottom, right)
     e.Graphics.DrawLine(Pens.Black, right, top)
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

Also for some reason the form dosn't repaint autmatically like it should always, so when ever you want to invoke or cause the OnPaint method to run in code just call me.invalidate or me.refresh.

Cut and paste that code into a sample form and run it to see it at work. Any more questions please feel free to ask. I tried to keep it really simple but I'm here if you need more details.

Also, this isn't a triangle, this is a diamond shape to the form. I didn't have time to draw your star shape but I suggest once you get it to use an array of points and the e.graphics.drawlines (pen, array of points here) to draw the star or triangles. Goodluck :)

I also have another post listed if you review my threads that shows some graphic renedering in realtime. It uses multithreading and what knot but may be interesting to you.
 
Last edited:
Thank you so much for your help.....

:) Thanks for your help. I sure will check your previous postings, and I will try the code that you help me with.

Hope that all works well.............

Blueeyes53:)
 
Thanks for the code... it did work fine!

Hi there,

This is what I need to know how to code:
The Splash screen should contain 2 triangles. These triangles should be created by drawing successively shorter lines.

These 2 triangles when put together resemble a rectangle.

Thanks a lot
:)
 
Well, I don't quite understand what your saying. I need more detail as to what you are doing and also I need to know do you want me to just write the code for you to use or are you trying to learn how to do it. I can write code all day but I prefer to teach what I know. Either way, I can send code with or without explanation. I thought the code and msg I provided was effiecient enough for you to make your own way with it. Please exaplain in more detail what it is your splash screen is doing.
 
From the 2 triangles thing, im getting this (see attached)

And if im right you want it to fade between colours? and that you want it drawn programmatically?

Maybe I am totally off but you are being quite vague
 

Attachments

  • img.GIF
    img.GIF
    2 KB · Views: 84
Thank you so much that it what I need , but I don't understand

:) Hi,
Yes that is the graphic that I need to draw, but I don't know how to write the code for it. Would you please write it for me so I could then work with the blending of the colors.

Thank you
Ps. I am just beginning in programming and, I am just walking baby steps.:)
 
This is all you need to make your form fade between colors in that fashion.

VB.NET:
[SIZE=2][COLOR=#0000ff]Protected [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnPaint([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] PaintEventArgs)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] a [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Drawing.Drawing2D.LinearGradientBrush([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientRectangle[/SIZE][SIZE=2], Color.Red, Color.Blue, Drawing2D.LinearGradientMode.ForwardDiagonal)
     e.Graphics.FillRectangle(a, [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientRectangle)
     a.Dispose()
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

Hope this is on track to getting you what you want. :)
 
Last edited:
Yes Thank you

Hi,

Yes it is something like that, but the are like a rectangle, but making 2 triangles - you know like one in its original form and the other upside down. I need the code to write these 2 triangles which are made drawing short lines.

Could you please paste the code for me.

Thanks:)
 
I don't understand this quest. Your questions and reasons aren't clear enough for me to grasp totally what's going on. I've shown you how to draw lines programmatically. I've shown you how to fade colors.

Here is the code now to draw two triangles in the way that craig listed above. The only difference is they are not filled in. Maybe this can help you. Without a lot more detail and a purpose I can't post anymore to this thread. Anyways, I hope this helps you realize what you are looking for.

Also, notice I moved the points + 5 or -5 to keep the lines away from the clientrectangle edges just so you can make out the lines better. You don't have to do it that way but that should give you an idea as to how to change the size the triangles.

Also, if the triangles are the same size, which they are here, you will notice that the center line on which they meet is over powered by whichever triangle was drawn last.

VB.NET:
[SIZE=2][COLOR=#0000ff]Protected [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnPaint([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] PaintEventArgs)
[/SIZE][SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] a [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Drawing.Drawing2D.LinearGradientBrush([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientRectangle, Color.Red, Color.Blue, Drawing2D.LinearGradientMode.ForwardDiagonal)
[/SIZE][SIZE=2][COLOR=#008000] 'points for triangle 1
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] T1(2) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Point
     T1(0) = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point(5, 5)
     T1(1) = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point(5, [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Height - 5)
     T1(2) = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Width - 5, 5)
[/SIZE][SIZE=2][COLOR=#008000] 'points for triangle 2
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Dim[/COLOR][/SIZE][SIZE=2] T2(2) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Point
     T2(0) = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Width - 5, [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Height - 5)
     T2(1) = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Width - 5, 5)
     T2(2) = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Point(5, [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize.Height - 5)
     e.Graphics.DrawPolygon(Pens.Red, T1)
     e.Graphics.DrawPolygon(Pens.Blue, T2)
     a.Dispose()
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
 
Last edited:
Back
Top