P
Peter Proost
Hi group,
I got the following piece of code which draws a square with stars round it,
now I want the stars to rotate round the square, I can do this with the
mx.rotate and a timer and an angle, but this rotates the whole drawing of
the stars but what I realy want is for the stars to rotate round it's center
point, is this possible? I hope I was clear enough in my explanation.
Thanks in advance
Peter
Imports System.Drawing.Drawing2D
Private pentje As New Pen(Color.White)
Private brush As New SolidBrush(Color.White)
Private hoek As Single
e.Graphics.FillRectangle(brush, 100, 100, 100, 100)
'Place inside form paint event
'Dim mx As New Matrix
'mx.Rotate(hoek, MatrixOrder.Append)
'mx.Translate(Me.ClientSize.Width / 2, Me.ClientSize.Height / 2,
MatrixOrder.Append)
'e.Graphics.Transform = mx
'grote ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 0)
e.Graphics.DrawLine(pentje, 150, 0, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 300, 150)
e.Graphics.DrawLine(pentje, 300, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 300)
e.Graphics.DrawLine(pentje, 150, 300, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 0, 150)
e.Graphics.DrawLine(pentje, 0, 150, 100, 100)
'kleine ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 25)
e.Graphics.DrawLine(pentje, 150, 25, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 275, 150)
e.Graphics.DrawLine(pentje, 275, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 275)
e.Graphics.DrawLine(pentje, 150, 275, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 25, 150)
e.Graphics.DrawLine(pentje, 25, 150, 100, 100)
'kleinere ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 50)
e.Graphics.DrawLine(pentje, 150, 50, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 250, 150)
e.Graphics.DrawLine(pentje, 250, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 250)
e.Graphics.DrawLine(pentje, 150, 250, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 50, 150)
e.Graphics.DrawLine(pentje, 50, 150, 100, 100)
'kleinste ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 75)
e.Graphics.DrawLine(pentje, 150, 75, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 225, 150)
e.Graphics.DrawLine(pentje, 225, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 225)
e.Graphics.DrawLine(pentje, 150, 225, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 75, 150)
e.Graphics.DrawLine(pentje, 75, 150, 100, 100)
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
hoek += 3
If hoek > 359 Then
hoek = 0
End If
Invalidate()
End Sub
I got the following piece of code which draws a square with stars round it,
now I want the stars to rotate round the square, I can do this with the
mx.rotate and a timer and an angle, but this rotates the whole drawing of
the stars but what I realy want is for the stars to rotate round it's center
point, is this possible? I hope I was clear enough in my explanation.
Thanks in advance
Peter
Imports System.Drawing.Drawing2D
Private pentje As New Pen(Color.White)
Private brush As New SolidBrush(Color.White)
Private hoek As Single
e.Graphics.FillRectangle(brush, 100, 100, 100, 100)
'Place inside form paint event
'Dim mx As New Matrix
'mx.Rotate(hoek, MatrixOrder.Append)
'mx.Translate(Me.ClientSize.Width / 2, Me.ClientSize.Height / 2,
MatrixOrder.Append)
'e.Graphics.Transform = mx
'grote ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 0)
e.Graphics.DrawLine(pentje, 150, 0, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 300, 150)
e.Graphics.DrawLine(pentje, 300, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 300)
e.Graphics.DrawLine(pentje, 150, 300, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 0, 150)
e.Graphics.DrawLine(pentje, 0, 150, 100, 100)
'kleine ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 25)
e.Graphics.DrawLine(pentje, 150, 25, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 275, 150)
e.Graphics.DrawLine(pentje, 275, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 275)
e.Graphics.DrawLine(pentje, 150, 275, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 25, 150)
e.Graphics.DrawLine(pentje, 25, 150, 100, 100)
'kleinere ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 50)
e.Graphics.DrawLine(pentje, 150, 50, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 250, 150)
e.Graphics.DrawLine(pentje, 250, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 250)
e.Graphics.DrawLine(pentje, 150, 250, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 50, 150)
e.Graphics.DrawLine(pentje, 50, 150, 100, 100)
'kleinste ster
e.Graphics.DrawLine(pentje, 100, 100, 150, 75)
e.Graphics.DrawLine(pentje, 150, 75, 200, 100)
e.Graphics.DrawLine(pentje, 200, 100, 225, 150)
e.Graphics.DrawLine(pentje, 225, 150, 200, 200)
e.Graphics.DrawLine(pentje, 200, 200, 150, 225)
e.Graphics.DrawLine(pentje, 150, 225, 100, 200)
e.Graphics.DrawLine(pentje, 100, 200, 75, 150)
e.Graphics.DrawLine(pentje, 75, 150, 100, 100)
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
hoek += 3
If hoek > 359 Then
hoek = 0
End If
Invalidate()
End Sub