Wieder mal ein Tipp für alle, die gern Grafiken
manipulieren und/oder etwas Abwechslung in Ihr Projekt bringen möchten und sei es nur das
besondere Intro.
- Um ein Demoprojekt zu erstellen benötigen Sie
1. Timer (Timer1) - Interval = 100
2. Picturebox - Name = piccopy
3. Picturebox - Name = picspin
- Kopieren Sie die nachfolgenden drei Prozeduren in
Ihr Projekt.
Allgemein/Do3DSpinBoth
Public Sub Do3DSpinBoth(picDestination As PictureBox, picSource As PictureBox, dblAmount
As Double, lLeftCol As Long, lRightcol As Long, lTopCol As Long, lBottomCol As Long)
Dim lHMidPoint As Long
Dim lVMidPoint As Long
Dim CosAmount As Double
Dim dblWidth As Double
Dim dblHeight As Double
CosAmount = Cos(dblAmount * 6.28)
lHMidPoint = picDestination.ScaleWidth / 2
lVMidPoint = picDestination.ScaleHeight / 2
k = 1 - Abs(CosAmount)
dblWidth = 2 * lHMidPoint * CosAmount
If Abs(dblWidth) < 1 Then dblWidth = 1 * Sgn(dblAmount)
dblHeight = 2 * lVMidPoint * CosAmount
If Abs(dblHeight) < 1 Then dblHeight = 1 * Sgn(dblAmount)
picDestination.Visible = False
picDestination.PaintPicture picSource.Picture, lHMidPoint * (1 - CosAmount), lVMidPoint *
(1 - CosAmount), dblWidth, dblHeight
picDestination.Line (0, 0)-(lHMidPoint * k, picDestination.ScaleHeight), lLeftCol, BF
picDestination.Line (picDestination.ScaleWidth - lHMidPoint * k,
0)-(picDestination.ScaleWidth, picDestination.ScaleHeight), lRightcol, BF
picDestination.Line (0, 0)-(picDestination.ScaleWidth, lVMidPoint * k), lTopCol, BF
picDestination.Line (0, picDestination.ScaleHeight - lVMidPoint *
k)-(picDestination.ScaleWidth, picDestination.ScaleHeight), lBottomCol, BF
picDestination.Picture = picDestination.Image
picDestination.Visible = True
End Sub
Allgemein/Do3DSpinHoriz
Public Sub Do3DSpinHoriz(picDestination As PictureBox, picSource As PictureBox, dblAmount
As Double, lLeftCol As Long, lRightcol As Long)
Dim lMidPoint As Long
Dim CosAmount As Double
Dim dblWidth As Double
CosAmount = Cos(dblAmount * 6.28)
lMidPoint = picDestination.ScaleWidth / 2
k = 1 - Abs(CosAmount)
dblWidth = 2 * lMidPoint * CosAmount
If Abs(dblWidth) < 1 Then dblWidth = 1 * Sgn(dblAmount)
picDestination.Visible = False
picDestination.PaintPicture picSource.Picture, lMidPoint * (1 - CosAmount), 0, dblWidth,
picDestination.ScaleHeight
picDestination.Line (0, 0)-(lMidPoint * k, picDestination.ScaleHeight), lLeftCol, BF
picDestination.Line (picDestination.ScaleWidth - lMidPoint * k,
0)-(picDestination.ScaleWidth, picDestination.ScaleHeight), lRightcol, BF
picDestination.Picture = picDestination.Image
picDestination.Visible = True
End Sub
Allgemein/Do3DSpinVert
Public Sub Do3DSpinVert(picDestination As PictureBox, picSource As PictureBox,
dblAmount As Double, lTopCol As Long, lBottomCol As Long)
Dim lMidPoint As Long
Dim CosAmount As Double
Dim dblHeight As Double
CosAmount = Cos(dblAmount * 6.28)
lMidPoint = picDestination.ScaleHeight / 2
k = 1 - Abs(CosAmount)
dblHeight = 2 * lMidPoint * CosAmount
If Abs(dblHeight) < 1 Then dblHeight = 1 * Sgn(dblAmount)
picDestination.Visible = False
picDestination.PaintPicture picSource.Picture, _
0, lMidPoint * (1 - CosAmount), picDestination.ScaleWidth, dblHeight
picDestination.Line (0, 0)-(picDestination.ScaleWidth, lMidPoint * k), lTopCol, BF
picDestination.Line (0, picDestination.ScaleHeight - lMidPoint *
k)-(picDestination.ScaleWidth, picDestination.ScaleHeight), lBottomCol, BF
picDestination.Picture = picDestination.Image
picDestination.Visible = True
End Sub
- Geben Sie dem Timer die Anweisung zum animieren
der Grafik.
Static curamount As Double
If IsEmpty(curamount) Then
curamount = 0.1
Else
curamount = curamount + 0.01
End If
If curamount > 1 Then curamount = curamount - 1
Do3DSpinBoth picspin, piccopy, curamount, BackColor, BackColor, Form1.BackColor,
Form1.BackColor
- Bevor Sie loslegen, müssen Sie in die Picturebox
(piccopy) noch eine Grafik laden. Stellen Sie außerdem die Visible Eigenschaft
auf False, denn diese Picturebox wird nur unsere Grafik lagern, mit dem eigentlichen
Ablauf hat sie nichts zu tun. Außerdem sollten Sie die Größe der Picturebox (picspin)
noch dem Format der Grafik anpassen, sonst sieht die Darstellung verzerrt aus.
- Wenn Sie nun Ihr Projekt mit F5 starten, werden
Sie sehen, wie Ihre Grafik ausgezoomt wird und gespiegelt wieder
Ihre alte Größe erreicht,
beim zweiten Durchlauf erscheint sie dann wieder richtig herum.
|