473,468 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Drawing Oval!

6 New Member
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
Mar 10 '08 #1
9 2642
douglandmesser
10 New Member
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.
Mar 10 '08 #2
Killer42
8,435 Recognized Expert Expert
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...

Expand|Select|Wrap|Line Numbers
  1. Dim S As Single
  2. For S = 0 to 6 Step 0.1
  3.   Me.Pset (50+Sin(S)*25, 50+Cos(S)*25)
  4. Next
  5.  
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.
Mar 11 '08 #3
debasisdas
8,127 Recognized Expert Expert
Please find a related article here .
Mar 11 '08 #4
parkho
6 New Member
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.
Mar 11 '08 #5
debasisdas
8,127 Recognized Expert Expert
Have you gone through the article provided in the link.
Mar 11 '08 #6
parkho
6 New Member
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
Mar 11 '08 #7
debasisdas
8,127 Recognized Expert Expert
Then what are you expecting the complete code ?
Mar 11 '08 #8
Killer42
8,435 Recognized Expert Expert
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?
Mar 12 '08 #9
Killer42
8,435 Recognized Expert Expert
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Click()
  2.   Dim S As Integer, Q As Double
  3.   Dim OffsetX As Single, OffsetY As Single
  4.   For S = 0 To 59
  5.     Q = Converted(S)
  6.     Select Case S
  7.       Case 0 To 14
  8.         OffsetX = (Abs(7 - Abs(7.5 - S))) * 5
  9.         OffsetY = (Abs(7 - Abs(7.5 - S))) * 5
  10. '      Case 15 To 29
  11. '        OffsetX = (Abs(7 - Abs(22.5 - S))) * 5
  12. '        OffsetY = (Abs(7 - Abs(22.5 - S))) * 5
  13.       Case 30 To 44
  14.         OffsetX = (Abs(7 - Abs(37.5 - S))) * 5
  15.         OffsetY = (Abs(7 - Abs(37.5 - S))) * 5
  16. '      Case 45 To 59
  17. '        OffsetX = (Abs(7 - Abs(52.5 - S))) * 5
  18. '        OffsetY = (Abs(7 - Abs(52.5 - S))) * 5
  19.       Case Else
  20.         OffsetX = 0
  21.         OffsetY = 0
  22.     End Select
  23.  
  24.     If S = 0 Then
  25.       Me.PSet (150 + Sin(Q) * (50 + OffsetX), 100 + Cos(Q) * (50 + OffsetY))
  26.     Else
  27.       Me.Line -(150 + Sin(Q) * (50 + OffsetX), 100 + Cos(Q) * (50 + OffsetY))
  28.     End If
  29.   Next
  30.  
  31. End Sub
  32.  
  33. Private Function Converted(What As Integer) As Double
  34.  
  35.   ' Note:
  36.   ' Step size = .105 (roughly)
  37.   ' Starting at 0 points us at 6 on the clock.
  38.   ' Therefore, about 3.15 should put us at 12 o'clock..
  39.  
  40.   Converted = (58 - What) * 0.1067 + 3.15
  41.  
  42. End Function
  43.  
If anyone plans to try it, the other point of note is that I set the form's ScaleMode to "3 - Pixel".
Mar 12 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
0
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...
7
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()...
3
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...
5
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...
0
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
4
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...
1
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...
2
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...
3
by: potupaul | last post by:
hii... plz help me out ,how to create rounded or oval buttons using c# in VS 2005.
1
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...
0
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...
0
marktang
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
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...
0
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...
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.