Hi,
I need help in coding a splash screen in VB.NET, it contains two traingles the first one varies the color green from 255 to 0, and the other varies the color blue 0 to 255, I tried different ideas but it didn't work, I'v been stuck with this for weeks now, please help, I know that I have to draw shorter lines with a different color each time but it still not working with me, please help.
Thank you

Dani AI

Generated

The original poster wanted two animated triangles on a VB.NET splash form: one whose green channel fades from 255 to 0, the other whose blue channel fades from 0 to 255. Replies asked for a screenshot (, ) and suggested a static pre-rendered image — simpler but inflexible. Below is a compact, practical approach that draws and animates two filled triangles on a borderless Form, uses double buffering to avoid flicker, and keeps the color math straightforward.

The example overrides painting and advances a step value with a Timer; green is computed as 255 - step and blue as step. Solid brushes are disposed with Using blocks; SmoothingMode is enabled for nicer edges. The Form is configured for typical splash behavior (no border, centered, no taskbar button). For smoother internal gradients instead of flat color fills, consider a PathGradientBrush (see PathGradientBrush docs) and for the polygon fill routine see Graphics.FillPolygon.

Public Class SplashForm
    Inherits Form

    Private WithEvents animTimer As New Timer() With {.Interval = 30}
    Private stepValue As Integer = 0
    Private dir As Integer = 1

    Public Sub New()
        Me.FormBorderStyle = FormBorderStyle.None
        Me.StartPosition = FormStartPosition.CenterScreen
        Me.ShowInTaskbar = False
        Me.TopMost = True

        SetStyle(ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)
        UpdateStyles()

        animTimer.Start()
    End Sub

    Private Sub animTimer_Tick(sender As Object, e As EventArgs) Handles animTimer.Tick
        stepValue += dir * 3
        If stepValue >= 255 Then stepValue = 255 : dir = -1
        If stepValue <= 0 Then stepValue = 0 : dir = 1
        Me.Invalidate()
    End Sub

    Protected Overrides Sub OnPaint(e As PaintEventArgs)
        MyBase.OnPaint(e)
        Dim gR As Graphics = e.Graphics
        gR.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias

        Dim w As Integer = ClientSize.Width
        Dim h As Integer = ClientSize.Height

        Dim tri1() As Point = {New Point(CInt(w*0.1), h-10), New Point(CInt(w*0.5), CInt(h*0.1)), New Point(CInt(w*0.9), h-10)}
        Dim tri2() As Point = {New Point(CInt(w*0.2), h-20), New Point(CInt(w*0.5), CInt(h*0.6)), New Point(CInt(w*0.8), h-20)}

        Dim gVal As Integer = 255 - stepValue
        Dim bVal As Integer = stepValue

        Using br1 As New SolidBrush(Color.FromArgb(0, gVal, 0))
            gR.FillPolygon(br1, tri1)
        End Using

        Using br2 As New SolidBrush(Color.FromArgb(0, 0, bVal))
            gR.FillPolygon(br2, tri2)
        End Using
    End Sub
End Class

Notes and troubleshooting: adjust Timer.Interval and the stepValue increment for speed; change triangle coordinates to match the desired layout; drawing order matters for overlaps; enable alpha via Color.FromArgb(alpha, r, g, b) if blending is required. If flicker persists, confirm SetStyle(...) is called before the Timer starts and that all brushes are disposed.

Recommended Answers

All 3 Replies

Member Avatar for Member #119018

Could you post a screen shot?

Right..., please post the screen shot what splashform that you want...

What about just creating the fade in a graphics program and setting the background image as a .jpg file or something?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.