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.
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.
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.
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.
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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.