Results 1 to 9 of 9

Thread: Fun with graphics

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Fun with graphics

    Ok, I'd like y'all to check this out, it doesn't teach anything about GDI+ but it's fun to look at.

    You need a project with a Form with a button (Button1)

    when you've started the prog, click the form and move the mouse around. (StepZ is controlled by the mousewheel)

    VB Code:
    1. Public Class Form1
    2.     Inherits System.Windows.Forms.Form
    3.  
    4.     '###
    5.     ' Windows Form Designer generated code
    6.     '###
    7.  
    8.     Private TheTimer As Timer
    9.     Private BM1 As New Bitmap(100, 100)
    10.     Private fgr As Graphics = Me.CreateGraphics
    11.  
    12.     Private StepX As Double = 16 ^ -1
    13.     Private StepY As Double = 12 ^ -1
    14.     Private StepZ As Double = 8 ^ -1
    15.  
    16.  
    17.     Private Sub Button1_Click(ByVal sender As System.Object, _
    18.                            ByVal e As System.EventArgs) Handles Button1.Click
    19.         If TheTimer Is Nothing Then
    20.             UpdateInfo()
    21.             TheTimer = New Timer
    22.             TheTimer.Interval = 50
    23.             AddHandler TheTimer.Tick, AddressOf Draw
    24.             TheTimer.Enabled = True
    25.         Else
    26.             TheTimer.Enabled = Not TheTimer.Enabled
    27.         End If
    28.     End Sub
    29.  
    30.     Private Sub Draw(ByVal Sender As Object, ByVal e As System.EventArgs)
    31.         Static OffsetX As Double = 0
    32.         Static OffsetY As Double = 0
    33.         Static OffsetZ As Double = 0
    34.         Static z As Integer = 0
    35.  
    36.         Dim y As Integer
    37.         Dim xred As Integer
    38.         Dim ygreen As Integer
    39.         Dim zblue As Integer = CInt((1 + Math.Sin(OffsetZ + z / BM1.Width * 2 * Math.PI)) * 127)
    40.  
    41.         For x As Integer = 0 To BM1.Width - 1
    42.             xred = CInt((1 + Math.Sin(OffsetX + x / BM1.Width * 2 * Math.PI)) * 127)
    43.  
    44.             For y = 0 To BM1.Height - 1
    45.                 ygreen = CInt((1 + Math.Sin(OffsetY + y / BM1.Height * 2 * Math.PI)) * 127)
    46.                 BM1.SetPixel(x, y, Color.FromArgb(xred, ygreen, zblue))
    47.  
    48.             Next y
    49.         Next x
    50.  
    51.         fgr.DrawImage(BM1, 0, 0, 600, 600)
    52.  
    53.         OffsetX += 2 * Math.PI * StepX
    54.         If OffsetX > 2 * Math.PI Then OffsetX -= 2 * Math.PI
    55.         OffsetY += 2 * Math.PI * StepY
    56.         If OffsetY > 2 * Math.PI Then OffsetY -= 2 * Math.PI
    57.         OffsetZ += 2 * Math.PI * StepZ
    58.         If OffsetZ > 2 * Math.PI Then OffsetZ -= 2 * Math.PI
    59.     End Sub
    60.  
    61.     Private Sub Form1_MouseMove(ByVal sender As Object, _
    62.                                               ByVal e As System.Windows.Forms.MouseEventArgs) _
    63.                                                   Handles MyBase.MouseMove
    64.         Const MaxStep As Double = 1 / 10
    65.         If e.Button = MouseButtons.Left Then
    66.             StepX = (1 + 2 * (e.X - Me.Width) / Me.Width) * MaxStep
    67.             StepY = (1 + 2 * (e.Y - Me.Width) / Me.Width) * MaxStep
    68.             UpdateInfo()
    69.         End If
    70.     End Sub
    71.  
    72.     Private Sub UpdateInfo()
    73.         Me.Text = "StepX:" & StepX.ToString("0.###") & _
    74.                   " StepY:" & StepY.ToString("0.###") & _
    75.                   " StepZ:" & StepZ.ToString("0.###")
    76.     End Sub
    77.  
    78.     Private Sub Form1_MouseWheel(ByVal sender As Object, _
    79.                                  ByVal e As System.Windows.Forms.MouseEventArgs) _
    80.                                  Handles MyBase.MouseWheel
    81.  
    82.         If Not e.Delta.Equals(0) Then
    83.             Select Case e.Delta > 0
    84.                 Case True
    85.                     StepZ += 0.005
    86.                     If StepZ > 0.1 Then StepZ = 0.1
    87.                 Case False
    88.                     StepZ -= 0.005
    89.                     If StepZ < -0.1 Then StepZ = -0.1
    90.             End Select
    91.             UpdateInfo()
    92.         End If
    93.  
    94.     End Sub
    95. End Class
    Last edited by grilkip; Jul 1st, 2005 at 03:26 PM. Reason: deleted some surpluss crap
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  2. #2
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: Fun with graphics

    That is very cool!

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fun with graphics

    Did you write this grilkip?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Fun with graphics

    Quote Originally Posted by RobDog888
    Did you write this grilkip?
    yes, I just did. Why? Does it suck?
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fun with graphics

    No, I was going to suggest it be moved to CodeBank VB.NET Forum if you did write it.
    Thats the proper place for it.

    I can move it if you like?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Fun with graphics

    Quote Originally Posted by RobDog888
    No, I was going to suggest it be moved to CodeBank VB.NET Forum if you did write it.
    Thats the proper place for it.

    I can move it if you like?
    Don't have a problem with that, I don't go there much so I didn't think of it.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Fun with graphics

    Moved to CodeBank VB.NET
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Lively Member sk8er_boi's Avatar
    Join Date
    Jun 2010
    Posts
    65

    Re: Fun with graphics

    pretty cool... thx =)

  9. #9
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Fun with graphics

    Super...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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