Results 1 to 36 of 36

Thread: Grafitti Effect

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308

    Grafitti Effect

    I recently saw a program written in VB that had a very nice looking, Grafitti type effect, for a background.

    This seems like the appropriate forum section to ask if anyone knows how to do that?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 'in a module
    2. Public Sub Grafitti(MyForm As Form)
    3.     Dim x As Integer
    4.     Dim Colo As Integer
    5.     Dim x1 As Integer
    6.     Dim x2 As Integer
    7.     Dim y1 As Integer
    8.     Dim y2 As Integer
    9.     If MyForm.WindowState = vbMinimized Then Exit Sub
    10.     MyForm.BackColor = vbBlack
    11.     MyForm.ScaleHeight = 100
    12.     MyForm.ScaleWidth = 100
    13.     For x = 0 To 300
    14.         DoEvents
    15.         x1 = Int(Rnd * 101)
    16.         x2 = Int(Rnd * 101)
    17.         y1 = Int(Rnd * 101)
    18.         y2 = Int(Rnd * 101)
    19.         Colo = Int(Rnd * 15)
    20.         MyForm.Line (x1, y1)-(x2, y2), QBColor(Colo)
    21.         MyForm.Line (x1, y2)-(x2, y1), QBColor(Colo)
    22.         MyForm.Line (x2, y1)-(x1, y2), QBColor(Colo)
    23.         MyForm.Line (y1, y2)-(x1, x2), QBColor(Colo)
    24.     Next x
    25. End Sub
    26.  
    27. 'on your form
    28. Private Sub Form_Resize()
    29. Grafitti Me
    30. End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    VERY COOL!!! I like it a lot!!!

    Fickle huh?

    (Yes, I saw your comment to Edneeis on the question I posted yesterday! )

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    indeed

    If you haven't tried what Hack posted, give it a shot. Its pretty cool.

    Any other ideas?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Just doing that routine taxed all of my graphic capability for a long time to come, but, how about animating the form's caption?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    I'm not sure what you mean by "animating the form's caption", so, sure.....whatchya got?

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    The FlashWindow API, I believe. After you declare it, you give it some parameters, and your form's handle, and the title bar blinks. Other than that you could change your title based on a timer or a loop...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Try this for your form's caption. I've finished playing around with it, and I kinda like the effect
    VB Code:
    1. Private Sub AnimateCaption(MyCaption As String, MyForm As Form)
    2.     Dim AddTitle As String
    3.     Dim Title As Long
    4.     MyForm.Show
    5.     MyForm.Caption = ""
    6.     AddTitle = MyCaption
    7.     For Title = 1 To Len(AddTitle)
    8.         ZoomLetter MyForm, Mid$(AddTitle, Title, 1), MyForm.Caption
    9.     Next
    10. End Sub
    11.  
    12. Private Sub ZoomLetter(MyForm As Form, NewLetter As String, OldCaption As String)
    13.     'Used By AnimateCaption
    14.     Dim Total As Integer
    15.     Dim Spaces As Integer
    16.     Dim Temp As String
    17.     Dim i As Integer
    18.     Total = Len(Temp)
    19.     Spaces = (MyForm.Width / 50) - (Total)
    20.     For i = Spaces To Len(Temp) Step -1
    21.         MyForm.Caption = OldCaption & Space(i) & NewLetter
    22.         DoEvents
    23.     Next
    24. End Sub
    25.  
    26. Private Sub Form_Load()
    27. AnimateCaption "Hows life in the world of litigation AttnSue?", Me
    28. End Sub

  10. #10
    Zaei
    Guest
    Here is a little modification to the animated caption:
    Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    
    Private Sub AnimateCaption(MyCaption As String, MyForm As Form)
        Dim AddTitle As String
        Dim Title As Long
        MyForm.Show
        MyForm.Caption = ""
        AddTitle = MyCaption
        For Title = 1 To Len(AddTitle)
            ZoomLetter MyForm, Mid$(AddTitle, Title, 1), MyForm.Caption
        Next
    End Sub
    
    Private Sub ZoomLetter(MyForm As Form, NewLetter As String, OldCaption As String)
        'Used By AnimateCaption
        Dim Total As Integer
        Dim Spaces As Integer
        Dim Temp As String
        Dim i As Integer
        If NewLetter = " " Then
            MyForm.Caption = MyForm.Caption & " "
            Exit Sub
        End If
        Total = Len(Temp)
        Spaces = (MyForm.Width / 50) - (Total)
        For i = Spaces To Len(Temp) Step -1
            MyForm.Caption = OldCaption & Space(i) & NewLetter
            DoEvents
            Sleep (5)
        Next
    End Sub
    
    Private Sub Form_Load()
    AnimateCaption "Hows life in the world of litigation AttnSue?", Me
    End Sub
    It simply adds a small pause to each step, which makes the animation smoother.

    Z.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I like it Zaei!!!

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    So do I Zaei. Nice job!

    Anyone else have a cool form effects?

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    How about playing some groovy music with the windows media control?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    I don't think music, "groovy" or otherwise would go over well in an Lawyers office, but thanks for the suggestion.

    I was more looking for visual effects, rather than auditory.

  15. #15
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Perhaps you could incorperate this.
    Attached Files Attached Files
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    Thanks SLH. I will definately check it out!

  17. #17
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Me too!

  18. #18
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Would be easy to convert so it was on a form as well, just change the object the pixels were drawn on, and a few max/min values and you're set.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    SLH: There is some very cool affects in your program, but how can I use it in mine. All your zip file contained was the .Exe

    Is this copywritten code?

  20. #20
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Sorry, i created the zip file a while ago, forgot it was just the exe.....
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  21. #21
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    There u go!
    Attached Files Attached Files
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  22. #22
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Figureing out where to draw the pixels is in the case statement: select case list1.listindex.

    The rest is for the trails, colours and user interface.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  23. #23
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Thanks!!! Nice job!!

  24. #24
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Try this one out
    VB Code:
    1. Private Sub HorizGradient(MyForm As Form, rs As Integer, gs As Integer, bs As Integer, re As Integer, ge As Integer, be As Integer, smooth As Boolean)
    2.     Dim ri As Integer
    3.     Dim gi As Integer
    4.     Dim bi As Integer
    5.     Dim rc As Integer
    6.     Dim bc As Integer
    7.     Dim gc As Integer
    8.     Dim x As Integer
    9.     If MyForm.WindowState = vbMinimized Then Exit Sub
    10.     MyForm.BackColor = RGB(re, ge, be)
    11.     If smooth = True Then
    12.         MyForm.DrawStyle = 6
    13.     Else
    14.         MyForm.DrawStyle = 0
    15.     End If
    16.     If MyForm.ScaleWidth <> 255 Then
    17.         MyForm.ScaleWidth = 255
    18.     End If
    19.     If MyForm.ScaleHeight <> 255 Then
    20.         MyForm.ScaleHeight = 255
    21.     End If
    22.     MyForm.DrawWidth = 5
    23.     MyForm.Refresh
    24.     ri = (rs - re) / 255
    25.     gi = (gs - ge) / 255
    26.     bi = (bs - be) / 255
    27.     rc = rs: bc = bs: gc = gs
    28.     For x = 0 To 255
    29.         MyForm.Line (x, 0)-(x, MyForm.ScaleHeight), RGB(rc, gc, bc)
    30.         rc = rc - ri
    31.         gc = gc - gi
    32.         bc = bc - bi
    33.     Next x
    34. End Sub
    35.  
    36. Private Sub Form_Resize()
    37. HorizGradient Form1, 111, 111, 222, 222, 255, 255, True
    38. 'or someother form of number combination
    39. End Sub

  25. #25
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Nice
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  26. #26
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Try this

    VB Code:
    1. Option Explicit
    2. Dim i As Integer
    3. Dim j As Integer
    4. Private Sub Form_Resize()
    5.     Cls
    6.     Call CurveForm(Me, vbBlack, 10)
    7. End Sub
    8. Private Sub CurveForm(Frm As Form, Colour As Long, Inc As Integer)
    9.     For i = 0 To 1000 Step Inc
    10.         Line (0, Frm.ScaleHeight / 1000 * i)-(Frm.ScaleWidth - (Frm.ScaleWidth / 1000 * i), 0), Colour
    11.        
    12.         Line (Frm.ScaleWidth, Frm.ScaleHeight / 1000 * i)-(Frm.ScaleWidth - (Frm.ScaleWidth / 1000 * i), Frm.ScaleHeight), Colour
    13.        
    14.         Line (0, Frm.ScaleHeight - (Frm.ScaleHeight / 1000 * i))-(Frm.ScaleWidth - (Frm.ScaleWidth / 1000 * i), Frm.ScaleHeight), Colour
    15.        
    16.         Line (Frm.ScaleWidth, Frm.ScaleHeight - (Frm.ScaleHeight / 1000 * i))-(Frm.ScaleWidth - (Frm.ScaleWidth / 1000 * i), 0), Colour
    17.     Next i
    18. End Sub
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  27. #27
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    A Cool Way To Close Your Form

    VB Code:
    1. Private Const AW_HOR_POSITIVE = &H1 'Animates the window from left to right. This flag can be used with roll or slide animation.
    2. Private Const AW_HOR_NEGATIVE = &H2 'Animates the window from right to left. This flag can be used with roll or slide animation.
    3. Private Const AW_VER_POSITIVE = &H4 'Animates the window from top to bottom. This flag can be used with roll or slide animation.
    4. Private Const AW_VER_NEGATIVE = &H8 'Animates the window from bottom to top. This flag can be used with roll or slide animation.
    5. Private Const AW_CENTER = &H10 'Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used.
    6. Private Const AW_HIDE = &H10000 'Hides the window. By default, the window is shown.
    7. Private Const AW_ACTIVATE = &H20000 'Activates the window.
    8. Private Const AW_SLIDE = &H40000 'Uses slide animation. By default, roll animation is used.
    9. Private Const AW_BLEND = &H80000 'Uses a fade effect. This flag can be used only if hwnd is a top-level window.
    10.  
    11. Private Declare Function AnimateWindow Lib "user32" (ByVal hwnd As Long, ByVal dwTime As Long, ByVal dwFlags As Long) As Boolean
    12.  
    13. Private Sub Form_Unload(Cancel As Integer)
    14.     'Animate the window
    15.     AnimateWindow Me.hwnd, 1000, AW_VER_POSITIVE Or AW_HOR_NEGATIVE Or AW_HIDE
    16.     'Unload our form completely
    17.     Set Form1 = Nothing
    18. End Sub

  28. #28

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308

    Well, well...

    It appears that SLH and Hack have been having some fun.

    Thanks guys. I can't wait to try all these new things out!!!!!

    Thanks a lot!!

  29. #29
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    I thought you might like this fade effect (I think it only works with windows with NT (2000,XP...)

    Just so people searching may find this (it's usefull).

    It fades the form, using alphablending, with the form and the background (what's behind the form).
    Attached Files Attached Files
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  30. #30
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You are probably correct on what platforms it works on. I just tried on my Win98 box, and the form just unloaded. Nothing else happened.

    I'll try on my WinNT4 box at home tonight and let you know if it works there.

  31. #31
    Zaei
    Guest
    Nice Fader, though WAYYY to slow. Visual effects should be pretty, but they shouldnt be a pain =).

    Z.

  32. #32
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    It works on NT4.

    Good job SLH!!

  33. #33
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    How bout some snow?

    VB Code:
    1. Dim Flake(500) As Coord
    2.  
    3. Private Type Coord
    4.     X As Integer
    5.     Y As Integer
    6. End Type
    7.  
    8. Private Sub Snow(Speed As Integer, Variation As Integer, Length As Integer)
    9.     Dim i&
    10.     For i& = 0 To 500
    11.         Flake(i&).X = Int(Rnd * Me.ScaleWidth)
    12.         Flake(i&).Y = -Int(Rnd * Length%)
    13.     Next i
    14.    
    15.     Do
    16.         DoEvents
    17.        
    18.         Dim dir%
    19.         Me.Refresh
    20.         For i& = 0 To 500
    21.             Randomize
    22.             dir% = Int(Rnd * 3)
    23.            
    24.             If dir% = 1 Then
    25.                 Flake(i&).X = Flake(i&).X + Variation%
    26.             ElseIf dir% = 2 Then
    27.                 Flake(i&).X = Flake(i&).X - Variation%
    28.             End If
    29.            
    30.             Flake(i&).Y = Flake(i&).Y + Sqr(Speed)
    31.             Me.PSet (Flake(i&).X, Flake(i&).Y), vbWhite
    32.         Next i
    33.     Loop
    34. End Sub
    35.  
    36. Private Sub Form_Load()
    37.     Me.ScaleMode = vbPixels
    38.     Me.BackColor = vbBlack
    39.     Me.Show
    40.     Snow 5, 1, 500
    41. End Sub
    42.  
    43. Private Sub Form_Unload(Cancel As Integer)
    44.     End
    45. End Sub

    It doesn't fade all that well in and out but just play with it.
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  34. #34
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Nice
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  35. #35
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    How about this nice effect..
    Attached Files Attached Files
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  36. #36
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Takes too much time.. would probably be OK if you slide-in all together...

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