Results 1 to 6 of 6

Thread: [RESOLVED] Getting rid of lines drawn under other lines

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2013
    Posts
    22

    Resolved [RESOLVED] Getting rid of lines drawn under other lines

    I'm trying to copy that microsoft screen saver with the moving line on a black background, and I've reached a barrier.
    Perhaps it's just best you look at my code before I try to explain myself, it could get confusing.
    Code:
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Randomize()
            g = Me.CreateGraphics
    
            While y1c = y2c
                y1c = 3 + CInt(7 * Rnd()) 'makes endpoint location change values different
            End While
    
            While x1c = x2c
                x1c = 3 + CInt(7 * Rnd())
            End While
    
            Me.BackColor = Color.Black
    
            Timer.Start()
    
        End Sub
    
        Dim i1 As Integer = CInt(255 * Rnd()) 'argb values
        Dim i2 As Integer = CInt(255 * Rnd())
        Dim i3 As Integer = CInt(255 * Rnd())
    
        Dim g As Graphics
    
        Dim x1 As Integer = CInt(Rnd(Me.Width)) 'line endpoint location values
        Dim y1 As Integer = CInt(Rnd(Me.Height))
        Dim x2 As Integer = CInt(Rnd(Me.Width))
        Dim y2 As Integer = CInt(Rnd(Me.Height))
    
        Dim x1c As Integer = 3 + CInt(7 * Rnd()) 'line endpoint location change values
        Dim y1c As Integer = 3 + CInt(7 * Rnd())
        Dim x2c As Integer = 3 + CInt(7 * Rnd())
        Dim y2c As Integer = 3 + CInt(7 * Rnd())
    
        Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles Timer.Tick
    
            i1 = i1 + 1
            i2 = i2 + 2
            i3 = i3 + 3
            If i1 > 255 Then i1 = 1
            If i2 > 254 Then i2 = 1
            If i3 > 253 Then i3 = 1
    
            x1 = x1 + x1c
            If x1 > Me.Width Or x1 < 0 Then x1c = x1c * -1
            y1 = y1 + y1c
            If y1 > Me.Height Or y1 < 0 Then y1c = y1c * -1
    
            x2 = x2 + x2c
            If x2 > Me.Width Or x2 < 0 Then x2c = x2c * -1
            y2 = y2 + y2c
            If y2 > Me.Height Or y2 < 0 Then y2c = y2c * -1
    
            g.DrawLine(New Pen(Color.FromArgb(i1, i2, i3), 1), New Point(x1, y1), New Point(x2, y2))
    
        End Sub
    End Class
    I just need help with getting rid of the lines that it has drawn after ~15 lines have been drawn after those *EFFICIENTLY*, so the screen doesn't feel so cluttered after a moment of it running.
    Thanks!
    Last edited by DinosaurusRex; May 31st, 2014 at 09:21 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width