We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

# Drawing a splash screen with two triangles having a gradient color scheme.

on
Medium Priority
226 Views

I need to draw a splash screen with two triangles having a gradient color scheme. The end result at the URL from this site is exactly what I need, except that I need to do it with a DrawLine method and Pen and Point objects and cannot determine how to do this.

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21552863.html?qid=21552863
Comment
Watch Question

## View Solution Only

Commented:
I don't see the point of using a point but you can do like this :

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim g As Graphics = e.Graphics

Dim myPen As New Pen(Color.Black)
For i As Integer = 0 To 255
myPen.Color = Color.FromArgb(255, i, 255)
g.DrawLine(myPen, 0, i, 255 - i, i)
myPen.Color = Color.FromArgb(255, 255, (255 - i))
g.DrawLine(myPen, (255 - i), i, 255, i)
Next

End Sub

Not the solution you were looking for? Getting a personalized solution is easy.

Commented:
Using points as well you will get :

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim g As Graphics = e.Graphics

Dim myPen As New Pen(Color.Black)
For i As Integer = 0 To 255
myPen.Color = Color.FromArgb(255, i, 255)
g.DrawLine(myPen, New Point(0, i), New Point(255 - i, i))
myPen.Color = Color.FromArgb(255, 255, (255 - i))
g.DrawLine(myPen, New Point(255 - i, i), New Point(255, i))

Next

End Sub

That should cover points, pen and drawline!
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Nice job, but you missed the gradient part.

Bob

Commented:
I calculate the new color while moving the lines down
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
My interpretation of the gradient would have been fill with a LinearGradientBrush, but actually who knows?

Bob

Commented:
Well, but that one was too easy I guess, it's way easier to implement it with a linearGradientBrush ofcourse, but how to do that using Point, DrawLine and Pen?
Due to these specs, I guess old school drawline with a varying color is the way to go :D
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
No, I meant filling something like a GraphicsPath with points defining the triangle area using a LinearGradientBrush, not drawing lines with a gradient brush.

But, ultimately, since this seems to be a question with no feedback from anyone but us, it's pointless to guess.

Bob

Commented:
heheh, you're right, but what you just mentioned was the original solution he put the ref to in the first place (so that's what he didnt want :D)
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
That, my friend, is a very good point ;)  LOL =:)

Bob

Commented:
The solution I needed was per a spec for an online class that I am taking for vb.net (newbie here) and unfortunately the teacher has not been much help with enabling me to understand the graphics class.

skip
##### Thanks for using Experts Exchange.

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile