| |
VB.NET - FortgeschritteneRe: Fade-In,Fade-Out nicht linear | | | Autor: Hannes H. | Datum: 26.12.06 09:41 |
| Hallo GPM
Auch mit deiner Function habe ich das Problem.
Eventuell ist das ja so und ich bräuchte eine andere.
Aber nochmal zum verdeutlichen:
Eine gerade, die Kontrollpunkte sind auf der geraden gleichmäßig aufgeteilt:
http://www.eisbaer-manager.de/downloads/Screen1.gif
Ziehe ich nun die 2 Kontrollpunkte mit der Maus, und berechne wieder, ist der Abstand zwischen den Punkten nicht gleichmäßig:
http://www.eisbaer-manager.de/downloads/Screen2.gif
Ich berechne die Punkte mittels deine Function in einer Schleife (For t = 0 to 1 step 0.2)
Daraus schließe ich, das die Strecke 0 - 1 für t zwar Anfang - Ende der Bezierkurve ist, jedoch diese nicht gleichmäßig diese Darstellt.
Je weiter ich den Kontrollpunkt 1 vom Anfang wegziehe, umso weiter wird dieser Abstand.
Hier nochmal mein Code:
Dim bzpoints() As Point = {New Point(50, 400), New Point(250, 400), New _
Point(400, 400), New Point(450, 100)}
Dim CheckPoint As New ArrayList
Dim gpath As New GraphicsPath
Dim curpoint As Int32
Dim ptsvisible As Boolean
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
curpoint = -1
If ptsvisible AndAlso gpath.IsVisible(New Point(e.X, e.Y)) Then
For i As Int32 = 1 To 2
If Math.Abs(e.X - bzpoints(i).X) < 6 AndAlso Math.Abs(e.Y - _
bzpoints(i).Y) < 6 Then
curpoint = i
End If
Next
End If
If e.Button = Windows.Forms.MouseButtons.Right Then
ptsvisible = Not ptsvisible
Me.Refresh()
End If
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
For Each h As Point In CheckPoint
e.Graphics.DrawPie(Pens.Green, h.X - 5, h.Y - 5, 10, 10, 0, 360)
Next
e.Graphics.DrawBezier(New Pen(Color.Yellow, 2), bzpoints(0), bzpoints( _
1), bzpoints(2), bzpoints(3))
If ptsvisible Then
gpath.Reset()
For i As Int32 = 0 To 3
gpath.AddEllipse(bzpoints(i).X - 5, bzpoints(i).Y - 5, 10, 10)
Next
e.Graphics.FillPath(Brushes.Red, gpath)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
CheckPoint.Add(New Point(0, 0))
Me.SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.UserPaint Or _
ControlStyles.AllPaintingInWmPaint, True)
Me.SetBounds(100, 100, 500, 500)
Me.BackColor = Color.Black
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If ptsvisible AndAlso curpoint > -1 AndAlso e.Button = _
Windows.Forms.MouseButtons.Left Then
bzpoints(curpoint) = New Point(e.X, e.Y)
Me.Refresh()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
bzpoints(0) = New Point(100, 400)
bzpoints(1) = New Point(200, 300)
bzpoints(2) = New Point(300, 200)
bzpoints(3) = New Point(400, 100)
Refresh()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button2.Click
Dim ay, ax, by, bx, cy, cx, pty, ptx, t As Double
CheckPoint.Clear()
For t = 0 To 1 Step 0.2
CheckPoint.Add(BezierPos(t))
Next
Refresh()
End Sub
Function BezierPos(ByVal t As Double) As Point
Dim p As Point
p.X = bzpoints(0).X * t ^ 3 + bzpoints(1).X * 3 * t ^ 2 * (1 - t) + _
bzpoints(2).X * 3 * t * (1 - t) ^ 2 + bzpoints(3).X * (1 - t) ^ 3
p.Y = bzpoints(0).Y * t ^ 3 + bzpoints(1).Y * 3 * t ^ 2 * (1 - t) + _
bzpoints(2).Y * 3 * t * (1 - t) ^ 2 + bzpoints(3).Y * (1 - t) ^ 3
Return p
End Function | |
Fade-In,Fade-Out nicht linear | 1.430 | Hannes H. | 24.12.06 10:44 | Re: Fade-In,Fade-Out nicht linear | 952 | GPM | 24.12.06 19:43 | Re: Fade-In,Fade-Out nicht linear | 941 | Hannes H. | 24.12.06 20:03 | Re: Fade-In,Fade-Out nicht linear | 899 | Hannes H. | 25.12.06 09:47 | Re: Fade-In,Fade-Out nicht linear | 914 | Hannes H. | 25.12.06 10:25 | Re: Fade-In,Fade-Out nicht linear | 932 | GPM | 25.12.06 14:39 | Re: Fade-In,Fade-Out nicht linear | 901 | Hannes H. | 25.12.06 16:16 | Re: Fade-In,Fade-Out nicht linear | 905 | Hannes H. | 25.12.06 17:05 | Re: Fade-In,Fade-Out nicht linear | 892 | GPM | 25.12.06 18:48 | Re: Fade-In,Fade-Out nicht linear | 1.096 | Hannes H. | 26.12.06 09:41 | Re: Fade-In,Fade-Out nicht linear | 930 | GPM | 26.12.06 11:34 | Re: Fade-In,Fade-Out nicht linear | 953 | GPM | 26.12.06 13:52 | Re: Fade-In,Fade-Out nicht linear | 898 | Hannes H. | 26.12.06 16:18 | Re: Fade-In,Fade-Out nicht linear | 904 | Hannes H. | 30.12.06 09:02 | Re: Fade-In,Fade-Out nicht linear | 1.044 | GPM | 30.12.06 09:59 | Re: Fade-In,Fade-Out nicht linear | 901 | GPM | 30.12.06 11:19 | Re: Fade-In,Fade-Out nicht linear | 882 | Hannes H. | 30.12.06 16:00 | Re: Fade-In,Fade-Out nicht linear | 911 | GPM | 30.12.06 17:29 | Re: Fade-In,Fade-Out nicht linear | 917 | Hannes H. | 30.12.06 18:37 | Re: Fade-In,Fade-Out nicht linear | 969 | GPM | 03.01.07 13:35 | Re: Fade-In,Fade-Out nicht linear | 927 | Hannes H. | 25.01.07 21:07 | Re: Fade-In,Fade-Out nicht linear | 861 | Hannes H. | 20.02.07 10:40 | Re: Fade-In,Fade-Out nicht linear | 971 | GPM | 20.02.07 12:16 | Re: Fade-In,Fade-Out nicht linear | 858 | Hannes H. | 20.02.07 15:50 | Re: Fade-In,Fade-Out nicht linear | 898 | Hannes H. | 23.02.07 09:34 | Re: Fade-In,Fade-Out nicht linear | 866 | Hannes H. | 23.02.07 09:38 | Re: Fade-In,Fade-Out nicht linear | 848 | GPM | 23.02.07 11:16 | Re: Fade-In,Fade-Out nicht linear | 872 | Hannes H. | 23.02.07 12:21 | Re: Fade-In,Fade-Out nicht linear | 992 | Hannes H. | 25.02.07 10:13 | Re: Fade-In,Fade-Out nicht linear | 888 | GPM | 25.02.07 11:54 | Re: Fade-In,Fade-Out nicht linear | 949 | GPM | 25.12.06 18:57 |
| Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
|
|
sevOutBar 4.0
Vertikale Menüleisten á la Outlook
Erstellen von Outlook ähnlichen Benutzer- interfaces - mit beliebig vielen Gruppen und Symboleinträgen. Moderner OfficeXP-Style mit Farbverläufen, Balloon-Tips, u.v.m. Weitere InfosTipp des Monats Access-Tools Vol.1
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|