hi, I have a form which I want to draw 4 Ovals with the same center point but with different directions so it looks like a star. I used the circle command which I can only get two Ovals on the desired direction and I cannot get the other two in right position. Please help me!
Thanks
9 2642
The best way to do what you want is to use SIN/COS functions. You can adjust the circle to do pretty much whatever you want. Give it a try. You will need to assign a value to PI. Also, use a FOR...NEXT loop for the actual 360 points on the circles. I have some code, but it's written in QB. You should be able to convert it to VB code quite easily. Let me know if you want it.
The best way to do what you want is to use SIN/COS functions. You can adjust the circle to do pretty much whatever you want. Give it a try. You will need to assign a value to PI. Also, use a FOR...NEXT loop for the actual 360 points on the circles. I have some code, but it's written in QB. You should be able to convert it to VB code quite easily. Let me know if you want it.
Actually, surprisingly enough you don't need to use Pi at all in drawing a circle. You just vary the X and Y coordinates that you draw based on Sin() and Cos() of a value. For example... -
Dim S As Single
-
For S = 0 to 6 Step 0.1
-
Me.Pset (50+Sin(S)*25, 50+Cos(S)*25)
-
Next
-
Sorry if this code isn't quite right, I don't have time to test it. Just typed it straight in here. Anyway, to produce an oval shape, you just change the ratio of what you add to the X and Y coordinates (Eg. add 25 to X and 10 to Y). To slant the oval, I guess you'd need to make a further variation.
Please find a related article here .
The best way to do what you want is to use SIN/COS functions. You can adjust the circle to do pretty much whatever you want. Give it a try. You will need to assign a value to PI. Also, use a FOR...NEXT loop for the actual 360 points on the circles. I have some code, but it's written in QB. You should be able to convert it to VB code quite easily. Let me know if you want it.
hi, thanks for the reply. Is it possible for you to post the code so I can some Idea? thanks so much.
Have you gone through the article provided in the link.
Have you gone through the article provided in the link.
yes I have. It gives me the basics of the Circle command which I already knew. my problem is that I want all the Ovals with the same center point NOT with different Center points. that looks like a star just like we turn them around at one center point.
Thanks
Then what are you expecting the complete code ?
I think there's one important question that we don't have a definite answer to as yet. You can produce interesting effects quite simply, by varying the aspect ratio of the circle (look up "circle" in the VB doco). That is, by making it taller or wider, so you get an oval shape. But that only makes horizontal/vertical ovals. Do you need tham at other angles as well?
If anyone's interested, here is some code where I was playing around with doing different offsets from the centre of the circle, depending on which "quarter" you're in. It's not terribly useful, but may inspire some ideas.
It uses a routine I wrote years ago for an analogue clock display, which takes a minute from 0 to 59 and converts it to the appropriate value to produce a point on the circle using Sin and Cos. that's why the code uses numbers from 0 to 59. - Private Sub Form_Click()
-
Dim S As Integer, Q As Double
-
Dim OffsetX As Single, OffsetY As Single
-
For S = 0 To 59
-
Q = Converted(S)
-
Select Case S
-
Case 0 To 14
-
OffsetX = (Abs(7 - Abs(7.5 - S))) * 5
-
OffsetY = (Abs(7 - Abs(7.5 - S))) * 5
-
' Case 15 To 29
-
' OffsetX = (Abs(7 - Abs(22.5 - S))) * 5
-
' OffsetY = (Abs(7 - Abs(22.5 - S))) * 5
-
Case 30 To 44
-
OffsetX = (Abs(7 - Abs(37.5 - S))) * 5
-
OffsetY = (Abs(7 - Abs(37.5 - S))) * 5
-
' Case 45 To 59
-
' OffsetX = (Abs(7 - Abs(52.5 - S))) * 5
-
' OffsetY = (Abs(7 - Abs(52.5 - S))) * 5
-
Case Else
-
OffsetX = 0
-
OffsetY = 0
-
End Select
-
-
If S = 0 Then
-
Me.PSet (150 + Sin(Q) * (50 + OffsetX), 100 + Cos(Q) * (50 + OffsetY))
-
Else
-
Me.Line -(150 + Sin(Q) * (50 + OffsetX), 100 + Cos(Q) * (50 + OffsetY))
-
End If
-
Next
-
-
End Sub
-
-
Private Function Converted(What As Integer) As Double
-
-
' Note:
-
' Step size = .105 (roughly)
-
' Starting at 0 points us at 6 on the clock.
-
' Therefore, about 3.15 should put us at 12 o'clock..
-
-
Converted = (58 - What) * 0.1067 + 3.15
-
-
End Function
-
If anyone plans to try it, the other point of note is that I set the form's ScaleMode to " 3 - Pixel".
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ron Adam |
last post by:
I want to be able to easily create reusable shapes in Tkinter and be
able to use them in mid level dialogs. So after some experimenting I've
managed to get something to work.
The following does...
|
by: Mike Starkey |
last post by:
I have created a transparent control and I am using to to create drawing objects Inside the transparent objects I have created I am trying to using the draw shapes oval, rectangle etc. An example...
|
by: Ben Bush |
last post by:
I tested the following code and wanted to get the message of "oval2
got hit" if I click the red one. But I always got "oval1 got hit".
from Tkinter import *
root=Tk()...
|
by: Mad Scientist Jr |
last post by:
I am looking to make a homegrown vector drawing tool, similar to making
vector drawings in Word or Powerpoint. It should be easy to use and
intuitive, like Word or the old MacDraw. I want to make...
|
by: Andrew Poulos |
last post by:
Is there a right/best way to draw an ellipse using Canvas? (With VML
there's the v:oval element which makes the exercise trivial). I tried
drawing a 360 degree arc (a circle) and then scaling it...
|
by: vabsjava |
last post by:
Hello Everybody.....
I want to use command button which is oval in shape.....
how to convert the button shaped in rectangle to oval....
please me in this regard...
Thank You
|
by: John Kotuby |
last post by:
Cleveland?
Hi all,
I am writing an ASP.NET 2.0 application in VB.NET. My boss doesn't like the
fact that I still use either rectangular or the default browser buttons on
my pages. He says it...
|
by: nish88 |
last post by:
Hi!! Actually,i am doing a simulation and i want a dot (small oval) to pop up when i click(by mouse) on the canvas.
can anyone please help me or if possible give me the piece of codes to perform...
|
by: ThatsIT.net.au |
last post by:
I have this code that writes a pie chart in a asp.net page, but I want to
use it in a server control.
When I try I get a error on the last line "Response.OutputStream"
Obviously there is no...
|
by: potupaul |
last post by:
hii...
plz help me out ,how to create rounded or oval buttons using c# in VS 2005.
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
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...
|
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 ...
| |