|
1pxとなりに透明からだんだん濃くなるように線を引き,同時に最初の線が濃い色からだんだん透明になるようにすれば, 線はかくかくと動かずぬるぬると動いているように見えるのではないでしょうか。 2本の線の合計の明るさが常に一定になるような条件が分からないと点滅するように見えてしまうかもしれませんが...
下は説明のためのコードです。透明度の制御は適当です。 Public Class Form1
Private WithEvents Timer1 As New Timer Private Const MinOpa As Integer = 48 Private Opa1 As Double = MinOpa Private x As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.BackColor = Color.Black Me.DoubleBuffered = True Me.Timer1.Interval = 100 Me.Timer1.Start() End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Me.Invalidate() Opa1 += 16 If Opa1 > 255 Then Opa1 = MinOpa x = (x + 10) Mod 100 End If End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim g As Graphics = e.Graphics Dim Opa2 As Integer = CInt(255 + MinOpa - Opa1) Dim Height As Integer = Me.ClientSize.Height g.FillRectangle(New SolidBrush(Color.FromArgb(Opa2, Color.Yellow)), x, 0, 10, Height) g.FillRectangle(New SolidBrush(Color.FromArgb(CInt(Opa1), Color.Yellow)), x + 10, 0, 10, Height) End Sub
End Class
|