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(Colo r.White)
Private hoek As Single
e.Graphics.Fill Rectangle(brush , 100, 100, 100, 100)
'Place inside form paint event
'Dim mx As New Matrix
'mx.Rotate(hoek , MatrixOrder.App end)
'mx.Translate(M e.ClientSize.Wi dth / 2, Me.ClientSize.H eight / 2,
MatrixOrder.App end)
'e.Graphics.Tra nsform = mx
'grote ster
e.Graphics.Draw Line(pentje, 100, 100, 150, 0)
e.Graphics.Draw Line(pentje, 150, 0, 200, 100)
e.Graphics.Draw Line(pentje, 200, 100, 300, 150)
e.Graphics.Draw Line(pentje, 300, 150, 200, 200)
e.Graphics.Draw Line(pentje, 200, 200, 150, 300)
e.Graphics.Draw Line(pentje, 150, 300, 100, 200)
e.Graphics.Draw Line(pentje, 100, 200, 0, 150)
e.Graphics.Draw Line(pentje, 0, 150, 100, 100)
'kleine ster
e.Graphics.Draw Line(pentje, 100, 100, 150, 25)
e.Graphics.Draw Line(pentje, 150, 25, 200, 100)
e.Graphics.Draw Line(pentje, 200, 100, 275, 150)
e.Graphics.Draw Line(pentje, 275, 150, 200, 200)
e.Graphics.Draw Line(pentje, 200, 200, 150, 275)
e.Graphics.Draw Line(pentje, 150, 275, 100, 200)
e.Graphics.Draw Line(pentje, 100, 200, 25, 150)
e.Graphics.Draw Line(pentje, 25, 150, 100, 100)
'kleinere ster
e.Graphics.Draw Line(pentje, 100, 100, 150, 50)
e.Graphics.Draw Line(pentje, 150, 50, 200, 100)
e.Graphics.Draw Line(pentje, 200, 100, 250, 150)
e.Graphics.Draw Line(pentje, 250, 150, 200, 200)
e.Graphics.Draw Line(pentje, 200, 200, 150, 250)
e.Graphics.Draw Line(pentje, 150, 250, 100, 200)
e.Graphics.Draw Line(pentje, 100, 200, 50, 150)
e.Graphics.Draw Line(pentje, 50, 150, 100, 100)
'kleinste ster
e.Graphics.Draw Line(pentje, 100, 100, 150, 75)
e.Graphics.Draw Line(pentje, 150, 75, 200, 100)
e.Graphics.Draw Line(pentje, 200, 100, 225, 150)
e.Graphics.Draw Line(pentje, 225, 150, 200, 200)
e.Graphics.Draw Line(pentje, 200, 200, 150, 225)
e.Graphics.Draw Line(pentje, 150, 225, 100, 200)
e.Graphics.Draw Line(pentje, 100, 200, 75, 150)
e.Graphics.Draw Line(pentje, 75, 150, 100, 100)
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As System.EventArg s)
Handles Timer1.Tick
hoek += 3
If hoek > 359 Then
hoek = 0
End If
Invalidate()
End Sub 2 2691
What you need it do is change the position of of where you draw the stars
each time you draw them. One way would be to setup the star as if you are
drawing at the origin. Then translate the Graphics object to the star's
rotate position. Next draw the star and then reset the Graphic object's
translation. Repeat this until all stars are drawn for that rotation part.
Robby
"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:OK******** ******@TK2MSFTN GP12.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(Colo r.White) Private hoek As Single
e.Graphics.Fill Rectangle(brush , 100, 100, 100, 100)
'Place inside form paint event 'Dim mx As New Matrix 'mx.Rotate(hoek , MatrixOrder.App end) 'mx.Translate(M e.ClientSize.Wi dth / 2, Me.ClientSize.H eight / 2, MatrixOrder.App end) 'e.Graphics.Tra nsform = mx
'grote ster e.Graphics.Draw Line(pentje, 100, 100, 150, 0) e.Graphics.Draw Line(pentje, 150, 0, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 300, 150) e.Graphics.Draw Line(pentje, 300, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 300) e.Graphics.Draw Line(pentje, 150, 300, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 0, 150) e.Graphics.Draw Line(pentje, 0, 150, 100, 100) 'kleine ster e.Graphics.Draw Line(pentje, 100, 100, 150, 25) e.Graphics.Draw Line(pentje, 150, 25, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 275, 150) e.Graphics.Draw Line(pentje, 275, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 275) e.Graphics.Draw Line(pentje, 150, 275, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 25, 150) e.Graphics.Draw Line(pentje, 25, 150, 100, 100) 'kleinere ster e.Graphics.Draw Line(pentje, 100, 100, 150, 50) e.Graphics.Draw Line(pentje, 150, 50, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 250, 150) e.Graphics.Draw Line(pentje, 250, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 250) e.Graphics.Draw Line(pentje, 150, 250, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 50, 150) e.Graphics.Draw Line(pentje, 50, 150, 100, 100) 'kleinste ster e.Graphics.Draw Line(pentje, 100, 100, 150, 75) e.Graphics.Draw Line(pentje, 150, 75, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 225, 150) e.Graphics.Draw Line(pentje, 225, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 225) e.Graphics.Draw Line(pentje, 150, 225, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 75, 150) e.Graphics.Draw Line(pentje, 75, 150, 100, 100)
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As System.EventArg s) Handles Timer1.Tick hoek += 3 If hoek > 359 Then hoek = 0 End If Invalidate() End Sub
Have you got some sample code? Because I'm not 100% sure how to go about
this
Thanks in advance
"Robby" <ed****@not.my. email.com> wrote in message
news:u3******** ******@TK2MSFTN GP14.phx.gbl... What you need it do is change the position of of where you draw the stars each time you draw them. One way would be to setup the star as if you are drawing at the origin. Then translate the Graphics object to the star's rotate position. Next draw the star and then reset the Graphic object's translation. Repeat this until all stars are drawn for that rotation
part. Robby
"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message news:OK******** ******@TK2MSFTN GP12.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(Colo r.White) Private hoek As Single
e.Graphics.Fill Rectangle(brush , 100, 100, 100, 100)
'Place inside form paint event 'Dim mx As New Matrix 'mx.Rotate(hoek , MatrixOrder.App end) 'mx.Translate(M e.ClientSize.Wi dth / 2, Me.ClientSize.H eight / 2, MatrixOrder.App end) 'e.Graphics.Tra nsform = mx
'grote ster e.Graphics.Draw Line(pentje, 100, 100, 150, 0) e.Graphics.Draw Line(pentje, 150, 0, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 300, 150) e.Graphics.Draw Line(pentje, 300, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 300) e.Graphics.Draw Line(pentje, 150, 300, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 0, 150) e.Graphics.Draw Line(pentje, 0, 150, 100, 100) 'kleine ster e.Graphics.Draw Line(pentje, 100, 100, 150, 25) e.Graphics.Draw Line(pentje, 150, 25, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 275, 150) e.Graphics.Draw Line(pentje, 275, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 275) e.Graphics.Draw Line(pentje, 150, 275, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 25, 150) e.Graphics.Draw Line(pentje, 25, 150, 100, 100) 'kleinere ster e.Graphics.Draw Line(pentje, 100, 100, 150, 50) e.Graphics.Draw Line(pentje, 150, 50, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 250, 150) e.Graphics.Draw Line(pentje, 250, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 250) e.Graphics.Draw Line(pentje, 150, 250, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 50, 150) e.Graphics.Draw Line(pentje, 50, 150, 100, 100) 'kleinste ster e.Graphics.Draw Line(pentje, 100, 100, 150, 75) e.Graphics.Draw Line(pentje, 150, 75, 200, 100) e.Graphics.Draw Line(pentje, 200, 100, 225, 150) e.Graphics.Draw Line(pentje, 225, 150, 200, 200) e.Graphics.Draw Line(pentje, 200, 200, 150, 225) e.Graphics.Draw Line(pentje, 150, 225, 100, 200) e.Graphics.Draw Line(pentje, 100, 200, 75, 150) e.Graphics.Draw Line(pentje, 75, 150, 100, 100)
Private Sub Timer1_Tick(ByV al sender As Object, ByVal e As System.EventArg s) Handles Timer1.Tick hoek += 3 If hoek > 359 Then hoek = 0 End If Invalidate() End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JustSomeGuy |
last post by:
mx = Cols/2;
if ((mx * 2) != Cols) // Odd.
++mx;
}
for (y1=0; y1 < Rows; ++y1)
{
y2 = Rows-1 - y1;
for (x1=0; x1 < mx; ++x1)
|
by: iwdu15 |
last post by:
hi, im trying to rotate a gdi drawn object on my form with a
keypress....forinstance when i push the down arrow, for it to rotate the
object drawn until the top is down, or if i push the right arrow key, to
rotate the object until its pointed to the right. i tried using a drawing
matrix to accomplish this, but all it did was rotate my entire form (im
drawing my object on the back of the form) and thats not what i need. I need
it to rotate...
|
by: Eduard Witteveen |
last post by:
Hello list,
I have code the draw MyDrawingObject information on a
System.Drawing.Graphics object. The code is more/less the following:
I now want to rotate / mirror the object i draw.
I've looked at the System.Drawing.Drawing2D.Matrix, which can be applied
on the Transform property of the Graphics object, but it will work on
the complete graphics object and there is no mirror method in it.
|
by: lovecreatesbeauty |
last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this
function works on a matrix of specific size, for example, it rotates a
4*4 matrix of integers in the following code. The function makes one
more copy of the original matrix, how is the efficiency? Can the copy
be saved? Comments on it are welcome.
Can I extend it to work on a matrix of any size (or even any type, not
just integers) for the logic may be the same when it...
|
by: Gina_Marano |
last post by:
Hey All,
Is it possible to draw an image upside down?
I am using Microsofts example of "Printing a local report without
preview".
The only trick is that I want to flip the image upside down.
Reason: I need to guarantee that I print a barcode in the exact same
| |
by: =?Utf-8?B?RGFu?= |
last post by:
I would like to draw an ellipse on a windows form and through mouse drags
stretch, rotate and relocate the ellipse.
Thanks in advance - Dan
|
by: =?Utf-8?B?dmlubw==?= |
last post by:
Hello,
I have created my proper control and i would to rotate it.
In the paint event of my object, i have written :
Dim graph As Graphics = myObject.CreateGraphics
myMatrix = New System.Drawing.Drawing2D.Matrix
myMatrix.Rotate(45, System.Drawing.Drawing2D.MatrixOrder.Append)
graph.Transform = myMatrix
but it don't work.
|
by: Syoam4ka |
last post by:
Hi, I have a WinApp in which I have a pictureBox.
I can draw in it like in the paint of windows - I accomplish that with an arrayList of Points and DrawLines method of the Graphics.
So it really paints like in the Paint of windows.
When I let the mouse left button up it stops drawing of course.
Now I want to rotate that paint (which is actually drawn lines isn't it)?
I have a button - btnRotateToLeft and another button -...
|
by: raylopez99 |
last post by:
I have a logical drawing space much bigger than the viewport (the
screen) and I'd like to center the viewport (the screen) to be at the
center of the logical drawing space. After following the excellent
transforms specified on Bob Powell's site, I still wonder if there's
an easier way of centering it than the following procedure?
Here is what I do now (it's awkward but it works):
1) I follow the transforms specified on Bob Powell's...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |