FORMULARIO COLOR DEGRADADO

    Public Sub paintForm(ByVal e As System.Windows.Forms.PaintEventArgs, ByVal direccionGradiente As String, ByVal color1 As Color, ByVal color2 As Color, ByVal frm As Form)
        Dim y As Integer = 0
        Dim x As Integer = 0
        Dim ancho As Integer = frm.Width
        Dim alto As Integer = frm.Height
        Dim Y_ As Integer = 0, X_ As Integer = 0
        Dim _Y As Integer = 0, _X As Integer = 0


        Try


            Select Case UCase(direccionGradiente)
                Case "TOP-BOTTOM"
                    _Y = y + alto
                    _X = x
                    Y_ = y
                    X_ = x
                Case "LEFT-RIGHT"
                    _Y = y
                    _X = x + ancho
                    Y_ = y
                    X_ = x
                Case "BOTTOM-TOP"
                    _Y = y
                    _X = x
                    Y_ = y + alto
                    X_ = x
                Case "RIGHT-LEFT"
                    _Y = y
                    _X = x
                    Y_ = y
                    X_ = x + alto
                Case Else
                    _Y = y
                    _X = x
                    Y_ = y + alto
                    X_ = x


            End Select


        Dim colorear As New LinearGradientBrush(New Point(X_, Y_), New Point(_X, _Y), color1, color2)


        e.Graphics.FillRectangle(colorear, x, y, ancho, alto)


        Catch ex As Exception


        End Try
    End Sub


    'Degradar desde el centro del form
    Public Sub paintForm2(ByVal e As System.Windows.Forms.PaintEventArgs, ByVal color1 As Color, ByVal color2 As Color, ByVal frm As Form)


        Dim y As Integer = 0
        Dim x As Integer = 0
        Dim ancho As Integer = frm.Width
        Dim alto As Integer = frm.Height
        Dim _Y As Integer = 0, _X As Integer = 0


        Try
            _Y = y + alto
            _X = x


            Dim colorear As New LinearGradientBrush(New Point(0, 0), New Point(0, _Y / 2), color1, color2)
            Dim colorear2 As New LinearGradientBrush(New Point(0, _Y / 2 - 1), New Point(0, _Y), color2, color1)


            Dim MED As Integer = alto / 2


            e.Graphics.FillRectangle(colorear, x, y, ancho, MED)
            e.Graphics.FillRectangle(colorear2, x, MED, ancho, MED)
        Catch ex As Exception


        End Try
    End Sub

1 comentario:

  1. un pregunta si yo quiero enviar el color degradado a un mapa de bits como puedo hacerlo es que no puedo hacer eso plis me puedes ayudar

    ResponderEliminar