[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

rotate drawing with matrix

Peter Proost

12/6/2004 10:09:00 AM

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


11 Answers

James Westgate

12/6/2004 10:33:00 AM

0

You need to use mx.RotateAt the centre, not this will also rotate your
rectangle, unless you reset youre transform and then draw your rectangle

James

--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.cra...

Take the ERM Tour at http://www.flowchartc...

"Peter Proost" <pproost@nospam.hotmail.com> wrote in message
news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
> 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
>
>


Peter Proost

12/6/2004 11:00:00 AM

0

Won't this rotate the entire star round a certain point? All I want it to do
is rotate it in place

Peter

"James Westgate" <jameswestgate@nospam.nospam> wrote in message
news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
> You need to use mx.RotateAt the centre, not this will also rotate your
> rectangle, unless you reset youre transform and then draw your rectangle
>
> James
>
> --
> Create interactive diagrams and flowcharts with ERM Diagram at
> http://www.cra...
>
> Take the ERM Tour at http://www.flowchartc...
>
> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
> > 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
> >
> >
>
>


James Westgate

12/6/2004 6:28:00 PM

0

Each star in place?

"Peter Proost" <pproost@nospam.hotmail.com> wrote in message
news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
> Won't this rotate the entire star round a certain point? All I want it to
> do
> is rotate it in place
>
> Peter
>
> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
>> You need to use mx.RotateAt the centre, not this will also rotate your
>> rectangle, unless you reset youre transform and then draw your rectangle
>>
>> James
>>
>> --
>> Create interactive diagrams and flowcharts with ERM Diagram at
>> http://www.cra...
>>
>> Take the ERM Tour at http://www.flowchartc...
>>
>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
>> > 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
>> >
>> >
>>
>>
>
>


Robby

12/7/2004 4:58:00 AM

0


An easy way to do this is to use the Graphics object's RotateTransform,
TranslateTransform and TransformPoints methods. We will be setting the
centre of the form as the origin (x=0, y=0) so you need to calculate the
centre of your form and store it so you can use it in your paint routine.

First work out the lines you need to use to have your star cantered at the
origin (x=0, y=0). For example, to draw a 60x60 box cantered at the origin
its start position at the upper left hand side would be (x=-30, y=-30). You
will need to store the line start and end points so that they are persevered
for successive calls to your paint routine and so that you can use them with
the TransformPoints method.

Next work out the positions of your stars from the origin which will be at
the centre of your form. For example, if the centre of one of your stars is
100 pixels directly above the centre then its position would be x=0, y=-100.
You will need to store these positions so that you can use them with the
TranslateTransform method.

To rotate your star ResetTransform on the Graphics object and then
RotateTransform with the degrees you want to rotate. Next pass the line
points to the TransformPoints method using a World-to-Page transformation.
Presto!! Your star is rotated. Remember that these points need to be
preserved for calls to your paint routine or you will only get a lean not a
rotation.

To draw your rotated star ResetTransform on the Graphics object then
TranslateTransform to the centre position + star position. For example if
your centre is (x=250, y=250) and your star position is (x=0, y=-100) then
your translation would be (x=250, y=150). Now draw your lines like normal.
Presto!!! You have a rotated star at the position. Now repeat this
paragraph for the remaining star positions.

For this method using a fixed border on the form you should be doing
paragraphs 1 to 3 when you start up. Paragraphs 4 and 5 are your paint
routine. Your stars will rotate about their centres in unison.

If you want more fun then you could also rotate your star positions when you
do the line points in paragraph 3 by calling TransformPoints with the star
positions. This will have the effect of the stars rotating about their
centres as they rotate about the centre of the form. Cool eh?

Hope this helps

Robby


"Peter Proost" <pproost@nospam.hotmail.com> wrote in message
news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
> Won't this rotate the entire star round a certain point? All I want it to
> do
> is rotate it in place
>
> Peter
>
> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
>> You need to use mx.RotateAt the centre, not this will also rotate your
>> rectangle, unless you reset youre transform and then draw your rectangle
>>
>> James
>>
>> --
>> Create interactive diagrams and flowcharts with ERM Diagram at
>> http://www.cra...
>>
>> Take the ERM Tour at http://www.flowchartc...
>>
>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
>> > 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
>> >
>> >
>>
>>
>
>


Robby

12/7/2004 5:06:00 AM

0


aarrhhh -- Spellcheck turned my centered to cantered. Switched to centred
below.

"Robby" <edmund@not.my.email.com> wrote in message
news:ebBOSlB3EHA.3820@TK2MSFTNGP11.phx.gbl...
>
> An easy way to do this is to use the Graphics object's RotateTransform,
> TranslateTransform and TransformPoints methods. We will be setting the
> centre of the form as the origin (x=0, y=0) so you need to calculate the
> centre of your form and store it so you can use it in your paint routine.
>
> First work out the lines you need to use to have your star centred at the
> origin (x=0, y=0). For example, to draw a 60x60 box centred at the origin
> its start position at the upper left hand side would be (x=-30, y=-30).
> You will need to store the line start and end points so that they are
> persevered for successive calls to your paint routine and so that you can
> use them with the TransformPoints method.
>
> Next work out the positions of your stars from the origin which will be at
> the centre of your form. For example, if the centre of one of your stars
> is 100 pixels directly above the centre then its position would be x=0,
> y=-100. You will need to store these positions so that you can use them
> with the TranslateTransform method.
>
> To rotate your star ResetTransform on the Graphics object and then
> RotateTransform with the degrees you want to rotate. Next pass the line
> points to the TransformPoints method using a World-to-Page transformation.
> Presto!! Your star is rotated. Remember that these points need to be
> preserved for calls to your paint routine or you will only get a lean not
> a rotation.
>
> To draw your rotated star ResetTransform on the Graphics object then
> TranslateTransform to the centre position + star position. For example if
> your centre is (x=250, y=250) and your star position is (x=0, y=-100) then
> your translation would be (x=250, y=150). Now draw your lines like
> normal. Presto!!! You have a rotated star at the position. Now repeat
> this paragraph for the remaining star positions.
>
> For this method using a fixed border on the form you should be doing
> paragraphs 1 to 3 when you start up. Paragraphs 4 and 5 are your paint
> routine. Your stars will rotate about their centres in unison.
>
> If you want more fun then you could also rotate your star positions when
> you do the line points in paragraph 3 by calling TransformPoints with the
> star positions. This will have the effect of the stars rotating about
> their centres as they rotate about the centre of the form. Cool eh?
>
> Hope this helps
>
> Robby
>
>
> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
>> Won't this rotate the entire star round a certain point? All I want it to
>> do
>> is rotate it in place
>>
>> Peter
>>
>> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
>> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
>>> You need to use mx.RotateAt the centre, not this will also rotate your
>>> rectangle, unless you reset youre transform and then draw your rectangle
>>>
>>> James
>>>
>>> --
>>> Create interactive diagrams and flowcharts with ERM Diagram at
>>> http://www.cra...
>>>
>>> Take the ERM Tour at http://www.flowchartc...
>>>
>>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
>>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
>>> > 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
>>> >
>>> >
>>>
>>>
>>
>>
>
>


Peter Proost

12/7/2004 7:47:00 AM

0

Thnx for all your help in the explanation, I'll check it out completely when
I've got time because I've got a demo of a program of mine in 15 minutes.

But thnx again.

Peter

"Robby" <edmund@not.my.email.com> wrote in message
news:#ifUwpB3EHA.2180@TK2MSFTNGP10.phx.gbl...
>
> aarrhhh -- Spellcheck turned my centered to cantered. Switched to centred
> below.
>
> "Robby" <edmund@not.my.email.com> wrote in message
> news:ebBOSlB3EHA.3820@TK2MSFTNGP11.phx.gbl...
> >
> > An easy way to do this is to use the Graphics object's RotateTransform,
> > TranslateTransform and TransformPoints methods. We will be setting the
> > centre of the form as the origin (x=0, y=0) so you need to calculate the
> > centre of your form and store it so you can use it in your paint
routine.
> >
> > First work out the lines you need to use to have your star centred at
the
> > origin (x=0, y=0). For example, to draw a 60x60 box centred at the
origin
> > its start position at the upper left hand side would be (x=-30, y=-30).
> > You will need to store the line start and end points so that they are
> > persevered for successive calls to your paint routine and so that you
can
> > use them with the TransformPoints method.
> >
> > Next work out the positions of your stars from the origin which will be
at
> > the centre of your form. For example, if the centre of one of your
stars
> > is 100 pixels directly above the centre then its position would be x=0,
> > y=-100. You will need to store these positions so that you can use them
> > with the TranslateTransform method.
> >
> > To rotate your star ResetTransform on the Graphics object and then
> > RotateTransform with the degrees you want to rotate. Next pass the line
> > points to the TransformPoints method using a World-to-Page
transformation.
> > Presto!! Your star is rotated. Remember that these points need to be
> > preserved for calls to your paint routine or you will only get a lean
not
> > a rotation.
> >
> > To draw your rotated star ResetTransform on the Graphics object then
> > TranslateTransform to the centre position + star position. For example
if
> > your centre is (x=250, y=250) and your star position is (x=0, y=-100)
then
> > your translation would be (x=250, y=150). Now draw your lines like
> > normal. Presto!!! You have a rotated star at the position. Now repeat
> > this paragraph for the remaining star positions.
> >
> > For this method using a fixed border on the form you should be doing
> > paragraphs 1 to 3 when you start up. Paragraphs 4 and 5 are your paint
> > routine. Your stars will rotate about their centres in unison.
> >
> > If you want more fun then you could also rotate your star positions when
> > you do the line points in paragraph 3 by calling TransformPoints with
the
> > star positions. This will have the effect of the stars rotating about
> > their centres as they rotate about the centre of the form. Cool eh?
> >
> > Hope this helps
> >
> > Robby
> >
> >
> > "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> > news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
> >> Won't this rotate the entire star round a certain point? All I want it
to
> >> do
> >> is rotate it in place
> >>
> >> Peter
> >>
> >> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> >> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
> >>> You need to use mx.RotateAt the centre, not this will also rotate your
> >>> rectangle, unless you reset youre transform and then draw your
rectangle
> >>>
> >>> James
> >>>
> >>> --
> >>> Create interactive diagrams and flowcharts with ERM Diagram at
> >>> http://www.cra...
> >>>
> >>> Take the ERM Tour at http://www.flowchartc...
> >>>
> >>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> >>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
> >>> > 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
> >>> >
> >>> >
> >>>
> >>>
> >>
> >>
> >
> >
>
>


Robby

12/7/2004 8:50:00 AM

0


I'll send a copy to you.

Robby

"Peter Proost" <pproost@nospam.hotmail.com> wrote in message
news:%23s0k9fD3EHA.3380@TK2MSFTNGP09.phx.gbl...
> Thnx for all your help in the explanation, I'll check it out completely
> when
> I've got time because I've got a demo of a program of mine in 15 minutes.
>
> But thnx again.
>
> Peter
>
> "Robby" <edmund@not.my.email.com> wrote in message
> news:#ifUwpB3EHA.2180@TK2MSFTNGP10.phx.gbl...
>>
>> aarrhhh -- Spellcheck turned my centered to cantered. Switched to centred
>> below.
>>
>> "Robby" <edmund@not.my.email.com> wrote in message
>> news:ebBOSlB3EHA.3820@TK2MSFTNGP11.phx.gbl...
>> >
>> > An easy way to do this is to use the Graphics object's RotateTransform,
>> > TranslateTransform and TransformPoints methods. We will be setting the
>> > centre of the form as the origin (x=0, y=0) so you need to calculate
>> > the
>> > centre of your form and store it so you can use it in your paint
> routine.
>> >
>> > First work out the lines you need to use to have your star centred at
> the
>> > origin (x=0, y=0). For example, to draw a 60x60 box centred at the
> origin
>> > its start position at the upper left hand side would be (x=-30, y=-30).
>> > You will need to store the line start and end points so that they are
>> > persevered for successive calls to your paint routine and so that you
> can
>> > use them with the TransformPoints method.
>> >
>> > Next work out the positions of your stars from the origin which will be
> at
>> > the centre of your form. For example, if the centre of one of your
> stars
>> > is 100 pixels directly above the centre then its position would be x=0,
>> > y=-100. You will need to store these positions so that you can use them
>> > with the TranslateTransform method.
>> >
>> > To rotate your star ResetTransform on the Graphics object and then
>> > RotateTransform with the degrees you want to rotate. Next pass the line
>> > points to the TransformPoints method using a World-to-Page
> transformation.
>> > Presto!! Your star is rotated. Remember that these points need to be
>> > preserved for calls to your paint routine or you will only get a lean
> not
>> > a rotation.
>> >
>> > To draw your rotated star ResetTransform on the Graphics object then
>> > TranslateTransform to the centre position + star position. For example
> if
>> > your centre is (x=250, y=250) and your star position is (x=0, y=-100)
> then
>> > your translation would be (x=250, y=150). Now draw your lines like
>> > normal. Presto!!! You have a rotated star at the position. Now repeat
>> > this paragraph for the remaining star positions.
>> >
>> > For this method using a fixed border on the form you should be doing
>> > paragraphs 1 to 3 when you start up. Paragraphs 4 and 5 are your paint
>> > routine. Your stars will rotate about their centres in unison.
>> >
>> > If you want more fun then you could also rotate your star positions
>> > when
>> > you do the line points in paragraph 3 by calling TransformPoints with
> the
>> > star positions. This will have the effect of the stars rotating about
>> > their centres as they rotate about the centre of the form. Cool eh?
>> >
>> > Hope this helps
>> >
>> > Robby
>> >
>> >
>> > "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
>> > news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
>> >> Won't this rotate the entire star round a certain point? All I want it
> to
>> >> do
>> >> is rotate it in place
>> >>
>> >> Peter
>> >>
>> >> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
>> >> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
>> >>> You need to use mx.RotateAt the centre, not this will also rotate
>> >>> your
>> >>> rectangle, unless you reset youre transform and then draw your
> rectangle
>> >>>
>> >>> James
>> >>>
>> >>> --
>> >>> Create interactive diagrams and flowcharts with ERM Diagram at
>> >>> http://www.cra...
>> >>>
>> >>> Take the ERM Tour at http://www.flowchartc...
>> >>>
>> >>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
>> >>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
>> >>> > 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
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>
>> >>
>> >
>> >
>>
>>
>
>


Peter Proost

12/7/2004 9:11:00 AM

0

Hi robby thanks for the example, but the demo was of a price calculating
programm and the stars is for an other program but thanks again for all the
effort and btw the demo went just fine :-) and I'm very relieved it did
because from january 2005, 2500 people will be using the programm daily. So
everybody happy :-)

Hope I Can help you out sometime,

Greetz Peter

"Robby" <edmund@not.my.email.com> wrote in message
news:#4v26mD3EHA.3472@TK2MSFTNGP09.phx.gbl...
>
> I'll send a copy to you.
>
> Robby
>
> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> news:%23s0k9fD3EHA.3380@TK2MSFTNGP09.phx.gbl...
> > Thnx for all your help in the explanation, I'll check it out completely
> > when
> > I've got time because I've got a demo of a program of mine in 15
minutes.
> >
> > But thnx again.
> >
> > Peter
> >
> > "Robby" <edmund@not.my.email.com> wrote in message
> > news:#ifUwpB3EHA.2180@TK2MSFTNGP10.phx.gbl...
> >>
> >> aarrhhh -- Spellcheck turned my centered to cantered. Switched to
centred
> >> below.
> >>
> >> "Robby" <edmund@not.my.email.com> wrote in message
> >> news:ebBOSlB3EHA.3820@TK2MSFTNGP11.phx.gbl...
> >> >
> >> > An easy way to do this is to use the Graphics object's
RotateTransform,
> >> > TranslateTransform and TransformPoints methods. We will be setting
the
> >> > centre of the form as the origin (x=0, y=0) so you need to calculate
> >> > the
> >> > centre of your form and store it so you can use it in your paint
> > routine.
> >> >
> >> > First work out the lines you need to use to have your star centred at
> > the
> >> > origin (x=0, y=0). For example, to draw a 60x60 box centred at the
> > origin
> >> > its start position at the upper left hand side would be (x=-30,
y=-30).
> >> > You will need to store the line start and end points so that they are
> >> > persevered for successive calls to your paint routine and so that you
> > can
> >> > use them with the TransformPoints method.
> >> >
> >> > Next work out the positions of your stars from the origin which will
be
> > at
> >> > the centre of your form. For example, if the centre of one of your
> > stars
> >> > is 100 pixels directly above the centre then its position would be
x=0,
> >> > y=-100. You will need to store these positions so that you can use
them
> >> > with the TranslateTransform method.
> >> >
> >> > To rotate your star ResetTransform on the Graphics object and then
> >> > RotateTransform with the degrees you want to rotate. Next pass the
line
> >> > points to the TransformPoints method using a World-to-Page
> > transformation.
> >> > Presto!! Your star is rotated. Remember that these points need to be
> >> > preserved for calls to your paint routine or you will only get a lean
> > not
> >> > a rotation.
> >> >
> >> > To draw your rotated star ResetTransform on the Graphics object then
> >> > TranslateTransform to the centre position + star position. For
example
> > if
> >> > your centre is (x=250, y=250) and your star position is (x=0, y=-100)
> > then
> >> > your translation would be (x=250, y=150). Now draw your lines like
> >> > normal. Presto!!! You have a rotated star at the position. Now
repeat
> >> > this paragraph for the remaining star positions.
> >> >
> >> > For this method using a fixed border on the form you should be doing
> >> > paragraphs 1 to 3 when you start up. Paragraphs 4 and 5 are your
paint
> >> > routine. Your stars will rotate about their centres in unison.
> >> >
> >> > If you want more fun then you could also rotate your star positions
> >> > when
> >> > you do the line points in paragraph 3 by calling TransformPoints with
> > the
> >> > star positions. This will have the effect of the stars rotating
about
> >> > their centres as they rotate about the centre of the form. Cool eh?
> >> >
> >> > Hope this helps
> >> >
> >> > Robby
> >> >
> >> >
> >> > "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> >> > news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
> >> >> Won't this rotate the entire star round a certain point? All I want
it
> > to
> >> >> do
> >> >> is rotate it in place
> >> >>
> >> >> Peter
> >> >>
> >> >> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> >> >> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
> >> >>> You need to use mx.RotateAt the centre, not this will also rotate
> >> >>> your
> >> >>> rectangle, unless you reset youre transform and then draw your
> > rectangle
> >> >>>
> >> >>> James
> >> >>>
> >> >>> --
> >> >>> Create interactive diagrams and flowcharts with ERM Diagram at
> >> >>> http://www.cra...
> >> >>>
> >> >>> Take the ERM Tour at http://www.flowchartc...
> >> >>>
> >> >>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> >> >>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
> >> >>> > 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
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>


Peter Proost

12/7/2004 2:10:00 PM

0

Hi Robby,

I read your example and I tried to draw a polygon and rotate it round it's
center but I'm doing something wrong. If I leave
e.Graphics.TranslateTransform(100, 100) out in the rotate part it seems to
rotate ok but at the wrong place. Sorry if these are dumb questions but I'm
new to this transforming stuff.

Thnx again for all you're time and effort

Greetz Peter


Private punten(5) As Point
Private bln As Boolean = False
Private pen As New SolidBrush(Color.Green)
Private hoek

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Try
If bln = False Then

e.Graphics.TransformPoints(Drawing.Drawing2D.CoordinateSpace.World, _
Drawing.Drawing2D.CoordinateSpace.World, punten)
e.Graphics.TranslateTransform(100, 100)
e.Graphics.FillPolygon(pen, punten)
bln = True
End If

e.Graphics.ResetTransform()
e.Graphics.RotateTransform(hoek)

e.Graphics.TransformPoints(Drawing.Drawing2D.CoordinateSpace.World, _
Drawing.Drawing2D.CoordinateSpace.Page, punten)
'If I comment this out it seems to rotate ok but at the wrong
place
e.Graphics.TranslateTransform(100, 100)
e.Graphics.FillPolygon(pen, punten)


Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub


Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
_ Handles MyBase.Load
punten(0) = New Point(0, -50)
punten(1) = New Point(25, 0)
punten(2) = New Point(25, 0)
punten(3) = New Point(0, 50)
punten(4) = New Point(-25, 0)
punten(5) = New Point(0, -50)
End Sub

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



"Peter Proost" <pproost@nospam.hotmail.com> wrote in message
news:eA1cnyD3EHA.3908@TK2MSFTNGP12.phx.gbl...
> Hi robby thanks for the example, but the demo was of a price calculating
> programm and the stars is for an other program but thanks again for all
the
> effort and btw the demo went just fine :-) and I'm very relieved it did
> because from january 2005, 2500 people will be using the programm daily.
So
> everybody happy :-)
>
> Hope I Can help you out sometime,
>
> Greetz Peter
>
> "Robby" <edmund@not.my.email.com> wrote in message
> news:#4v26mD3EHA.3472@TK2MSFTNGP09.phx.gbl...
> >
> > I'll send a copy to you.
> >
> > Robby
> >
> > "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> > news:%23s0k9fD3EHA.3380@TK2MSFTNGP09.phx.gbl...
> > > Thnx for all your help in the explanation, I'll check it out
completely
> > > when
> > > I've got time because I've got a demo of a program of mine in 15
> minutes.
> > >
> > > But thnx again.
> > >
> > > Peter
> > >
> > > "Robby" <edmund@not.my.email.com> wrote in message
> > > news:#ifUwpB3EHA.2180@TK2MSFTNGP10.phx.gbl...
> > >>
> > >> aarrhhh -- Spellcheck turned my centered to cantered. Switched to
> centred
> > >> below.
> > >>
> > >> "Robby" <edmund@not.my.email.com> wrote in message
> > >> news:ebBOSlB3EHA.3820@TK2MSFTNGP11.phx.gbl...
> > >> >
> > >> > An easy way to do this is to use the Graphics object's
> RotateTransform,
> > >> > TranslateTransform and TransformPoints methods. We will be setting
> the
> > >> > centre of the form as the origin (x=0, y=0) so you need to
calculate
> > >> > the
> > >> > centre of your form and store it so you can use it in your paint
> > > routine.
> > >> >
> > >> > First work out the lines you need to use to have your star centred
at
> > > the
> > >> > origin (x=0, y=0). For example, to draw a 60x60 box centred at the
> > > origin
> > >> > its start position at the upper left hand side would be (x=-30,
> y=-30).
> > >> > You will need to store the line start and end points so that they
are
> > >> > persevered for successive calls to your paint routine and so that
you
> > > can
> > >> > use them with the TransformPoints method.
> > >> >
> > >> > Next work out the positions of your stars from the origin which
will
> be
> > > at
> > >> > the centre of your form. For example, if the centre of one of your
> > > stars
> > >> > is 100 pixels directly above the centre then its position would be
> x=0,
> > >> > y=-100. You will need to store these positions so that you can use
> them
> > >> > with the TranslateTransform method.
> > >> >
> > >> > To rotate your star ResetTransform on the Graphics object and then
> > >> > RotateTransform with the degrees you want to rotate. Next pass the
> line
> > >> > points to the TransformPoints method using a World-to-Page
> > > transformation.
> > >> > Presto!! Your star is rotated. Remember that these points need to
be
> > >> > preserved for calls to your paint routine or you will only get a
lean
> > > not
> > >> > a rotation.
> > >> >
> > >> > To draw your rotated star ResetTransform on the Graphics object
then
> > >> > TranslateTransform to the centre position + star position. For
> example
> > > if
> > >> > your centre is (x=250, y=250) and your star position is (x=0,
y=-100)
> > > then
> > >> > your translation would be (x=250, y=150). Now draw your lines like
> > >> > normal. Presto!!! You have a rotated star at the position. Now
> repeat
> > >> > this paragraph for the remaining star positions.
> > >> >
> > >> > For this method using a fixed border on the form you should be
doing
> > >> > paragraphs 1 to 3 when you start up. Paragraphs 4 and 5 are your
> paint
> > >> > routine. Your stars will rotate about their centres in unison.
> > >> >
> > >> > If you want more fun then you could also rotate your star positions
> > >> > when
> > >> > you do the line points in paragraph 3 by calling TransformPoints
with
> > > the
> > >> > star positions. This will have the effect of the stars rotating
> about
> > >> > their centres as they rotate about the centre of the form. Cool
eh?
> > >> >
> > >> > Hope this helps
> > >> >
> > >> > Robby
> > >> >
> > >> >
> > >> > "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> > >> > news:umHyQL42EHA.1124@tk2msftngp13.phx.gbl...
> > >> >> Won't this rotate the entire star round a certain point? All I
want
> it
> > > to
> > >> >> do
> > >> >> is rotate it in place
> > >> >>
> > >> >> Peter
> > >> >>
> > >> >> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> > >> >> news:eXToF832EHA.1264@TK2MSFTNGP12.phx.gbl...
> > >> >>> You need to use mx.RotateAt the centre, not this will also rotate
> > >> >>> your
> > >> >>> rectangle, unless you reset youre transform and then draw your
> > > rectangle
> > >> >>>
> > >> >>> James
> > >> >>>
> > >> >>> --
> > >> >>> Create interactive diagrams and flowcharts with ERM Diagram at
> > >> >>> http://www.cra...
> > >> >>>
> > >> >>> Take the ERM Tour at http://www.flowchartc...
> > >> >>>
> > >> >>> "Peter Proost" <pproost@nospam.hotmail.com> wrote in message
> > >> >>> news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
> > >> >>> > 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
> > >> >>> >
> > >> >>> >
> > >> >>>
> > >> >>>
> > >> >>
> > >> >>
> > >> >
> > >> >
> > >>
> > >>
> > >
> > >
> >
> >
>
>


Bob Powell

12/7/2004 3:31:00 PM

0

Like this??

(after my signature)

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


------------------------------------------------------------------------
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)



Dim mx As New Matrix

mx.Translate((Me.ClientSize.Width / 2) - 150, (Me.ClientSize.Height / 2) -
150, MatrixOrder.Append)

e.Graphics.Transform = mx

e.Graphics.FillRectangle(brush, 100, 100, 100, 100)

'Place inside form paint event

mx = New Matrix

mx.RotateAt(hoek, New PointF(150, 150), MatrixOrder.Append)

mx.Translate((Me.ClientSize.Width / 2) - 150, (Me.ClientSize.Height / 2) -
150, 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)

End Sub

------------------------------------------------------------------------


"Peter Proost" <pproost@nospam.hotmail.com> wrote in message
news:Od8Yau32EHA.924@TK2MSFTNGP14.phx.gbl...
> 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
>
>