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.

Skiprrr
Skiprrr asked
on
Medium Priority
226 Views
Last Modified: 2010-04-23

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

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.

Ask the Experts
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
It is gradient, isnt it?
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
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
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

Author

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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

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

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.