|
-
Jul 1st, 2005, 02:29 PM
#1
Thread Starter
Fanatic Member
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:
Public Class Form1
Inherits System.Windows.Forms.Form
'###
' Windows Form Designer generated code
'###
Private TheTimer As Timer
Private BM1 As New Bitmap(100, 100)
Private fgr As Graphics = Me.CreateGraphics
Private StepX As Double = 16 ^ -1
Private StepY As Double = 12 ^ -1
Private StepZ As Double = 8 ^ -1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If TheTimer Is Nothing Then
UpdateInfo()
TheTimer = New Timer
TheTimer.Interval = 50
AddHandler TheTimer.Tick, AddressOf Draw
TheTimer.Enabled = True
Else
TheTimer.Enabled = Not TheTimer.Enabled
End If
End Sub
Private Sub Draw(ByVal Sender As Object, ByVal e As System.EventArgs)
Static OffsetX As Double = 0
Static OffsetY As Double = 0
Static OffsetZ As Double = 0
Static z As Integer = 0
Dim y As Integer
Dim xred As Integer
Dim ygreen As Integer
Dim zblue As Integer = CInt((1 + Math.Sin(OffsetZ + z / BM1.Width * 2 * Math.PI)) * 127)
For x As Integer = 0 To BM1.Width - 1
xred = CInt((1 + Math.Sin(OffsetX + x / BM1.Width * 2 * Math.PI)) * 127)
For y = 0 To BM1.Height - 1
ygreen = CInt((1 + Math.Sin(OffsetY + y / BM1.Height * 2 * Math.PI)) * 127)
BM1.SetPixel(x, y, Color.FromArgb(xred, ygreen, zblue))
Next y
Next x
fgr.DrawImage(BM1, 0, 0, 600, 600)
OffsetX += 2 * Math.PI * StepX
If OffsetX > 2 * Math.PI Then OffsetX -= 2 * Math.PI
OffsetY += 2 * Math.PI * StepY
If OffsetY > 2 * Math.PI Then OffsetY -= 2 * Math.PI
OffsetZ += 2 * Math.PI * StepZ
If OffsetZ > 2 * Math.PI Then OffsetZ -= 2 * Math.PI
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles MyBase.MouseMove
Const MaxStep As Double = 1 / 10
If e.Button = MouseButtons.Left Then
StepX = (1 + 2 * (e.X - Me.Width) / Me.Width) * MaxStep
StepY = (1 + 2 * (e.Y - Me.Width) / Me.Width) * MaxStep
UpdateInfo()
End If
End Sub
Private Sub UpdateInfo()
Me.Text = "StepX:" & StepX.ToString("0.###") & _
" StepY:" & StepY.ToString("0.###") & _
" StepZ:" & StepZ.ToString("0.###")
End Sub
Private Sub Form1_MouseWheel(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles MyBase.MouseWheel
If Not e.Delta.Equals(0) Then
Select Case e.Delta > 0
Case True
StepZ += 0.005
If StepZ > 0.1 Then StepZ = 0.1
Case False
StepZ -= 0.005
If StepZ < -0.1 Then StepZ = -0.1
End Select
UpdateInfo()
End If
End Sub
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
-
Jul 1st, 2005, 02:37 PM
#2
Frenzied Member
-
Jul 1st, 2005, 03:04 PM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 1st, 2005, 03:15 PM
#4
Thread Starter
Fanatic Member
Re: Fun with graphics
 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
-
Jul 1st, 2005, 03:33 PM
#5
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jul 1st, 2005, 03:36 PM
#6
Thread Starter
Fanatic Member
Re: Fun with graphics
 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
-
Jul 1st, 2005, 03:50 PM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 22nd, 2010, 02:27 AM
#8
Lively Member
-
Jun 22nd, 2010, 09:01 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|