Hi Spoo. I have been very silly. I did not notice that the pbAA.ScaleWidth line was missing from my copy of your code. The result, which I cannot say I fully understand (but which I am quite willing to NOT understand for the moment) was that the Circle was drawn properly but the Dots which should have been positioned on the Circle were not, except on the X-axis. That is, the shape of the Dots was an ellipse, 'squished' in the Y-axis. Any other 'circular' object I drew within the original circle was also 'squished' in the Y-axis. Anyway it was just my stupidity.
I do not know what is the ettiquette for what I am about to do - if I am doing wrong someone can let me know and I wont do it again.
Here is your code that I have been taking some liberties with, if you know what I mean. In other words here is the gauge I have created from your code. It's not the finished, polished item, or course. There are many things that could be improved (only need 1 array to hold the scale values, for instance). Am using Copy and Paste so hope this works out OK.
'// Start Code
'// The form, Form1, is 3540 high and 5265 wide. There is a PictureBox called pbAA
'// positioned to the centre, left of the form. To the right are a Text Box, called
'// txtInput and two Option Button called optImp and optMetric.
Sub Gauges()
With pbAA
.Top = 100
.Left = 200
.Height = 3000
.Width = 3000
.ZOrder 0
.Visible = True
.ScaleHeight = 8000
.ScaleWidth = 8000
.ScaleMode = 0
.BorderStyle = 0
.BackColor = &H8000000B 'Set to the same colour as the form, Form1.
End With
Update
End Sub
Private Sub Form_Load()
optMetric = True
'// Clear the display
pbAA.Cls
Gauges
End Sub
Sub Update()
With pbAA
'1. Clear the screen (for each new needle position)
.Cls
'Regenerate the gauge each time
'2. Draw the Outer Gauge Circle
ccx = 4000 'x coord centre
ccy = 4000 'y coord centre
rGauge = 3000 'radius of outer Gauge circle
rScale = 2700 'radius of inner scale arc
rMinor = 2520 'radius of Minor scale marker
rMajor = 2340 'radius of Major scale marker
rDot = 50 'radius of Needle Center 'Dot'
rNeedle = 1500 'radius of the Pointer or Needle
cc = RGB(0, 0, 0) 'Black
.DrawWidth = 3
pbAA.Circle (ccx, ccy), rGauge, cc 'Draw the outer circle
'// Make the pbAA PictureBox BackColor Property the same color as the form (Form1)
'// Make the pbAA PictureBox BorderStyle Property 0-None
'// Now give the gauge a white 'face'
.FillStyle = 0
.FillColor = RGB(255, 255, 255)
'3a. Draw an inner 'scale' arc from 315 degrees to 255 degrees anticlockwise
.DrawWidth = 1
pbAA.Circle (ccx, ccy), rScale, cc, 5.4978, 3.927
'3b. Create scale markers
.DrawWidth = 1
Dim aCos(40), aSin(40) 'arrays to hold the results
'Create a scale - place a minor marker at each 9 degree
'poition. Place a major marker at each 45 degree position
For ii = 0 To 39
'Need to skip 6 to 14, the portion of the circle that is not in the arc
If (ii > 5) And (ii < 15) Then
GoTo Skip
End If
radn = (ii * 9) * (3.1416 / 180) 'Convert degrees to radians
aCos(ii) = Cos(radn)
aSin(ii) = Sin(radn)
'Locate the point on the scale arc
xx1 = aCos(ii) * rScale + ccx
yy1 = aSin(ii) * rScale + ccy
'Locate the required inner position point - 1st for the Minor scale position
MinorXX = aCos(ii) * rMinor + ccx
MinorYY = aSin(ii) * rMinor + ccy
'Then for the Major scale position
MajorXX = aCos(ii) * rMajor + ccx
MajorYY = aSin(ii) * rMajor + ccy
'Draw the scale markers
If ((ii * 9) Mod 45) = 0 Then
'Draw the major marker
.DrawWidth = 2
pbAA.Line (xx1, yy1)-(MajorXX, MajorYY), 0
Else
'Draw the minor marker
.DrawWidth = 1
pbAA.Line (xx1, yy1)-(MinorXX, MinorYY), 0
End If
Skip:
Next ii
'3c. Add a numeric scale, i.e. print numbers on the major scale markers
Dim arrScaleMetric(7) As String, arrScaleImp(7) As String
'Populate the arrays
ImpInc = 5
MetInc = 10
arrScaleImp(3) = 0
arrScaleImp(4) = 5
arrScaleImp(5) = 10
arrScaleImp(6) = 15
arrScaleImp(7) = 20
arrScaleImp(0) = 25
arrScaleImp(1) = 30
arrScaleImp(2) = ""
arrScaleMetric(3) = 0
arrScaleMetric(4) = 10
arrScaleMetric(5) = 20
arrScaleMetric(6) = 30
arrScaleMetric(7) = 40
arrScaleMetric(0) = 50
arrScaleMetric(1) = 60
arrScaleMetric(2) = ""
'The metric array now contains the scale values for the metric gauge
'The imperial array now contains the scale values for the imperial gauge
For Index = 0 To 7
If Index = 2 Then
Index = Index + 1
End If
rValues = 1800
If optImp = True Then
txtH = pbAA.TextHeight(arrScaleImp(Index))
txtW = pbAA.TextWidth(arrScaleImp(Index))
pbAA.CurrentX = aCos(Index * 5) * rValues + ccx - (0.5 * txtW)
pbAA.CurrentY = aSin(Index * 5) * rValues + ccy - (0.5 * txtH)
pbAA.Print (arrScaleImp(Index))
Else
txtH = pbAA.TextHeight(arrScaleMetric(Index))
txtW = pbAA.TextWidth(arrScaleMetric(Index))
pbAA.CurrentX = aCos(Index * 5) * rValues + ccx - (0.5 * txtW)
pbAA.CurrentY = aSin(Index * 5) * rValues + ccy - (0.5 * txtH)
pbAA.Print (arrScaleMetric(Index))
End If
Next Index
'4a. Draw the needle
.DrawWidth = 2
xxi = ccx
yyi = ccy
'The scale operates from 135 degrees to 45 degrees clockwise and displays from
'0 to 30 MPH or from 0 to 60 km/h
'Each MPH has an increment of 9 degrees. Each km/h has an increment of 4.5 degrees
'0 on the scales is at (clockwise) 135 degrees. Full scale (30MPH) is at (clockwise)
'45 degrees
If txtInput.Text = "" Then
iValue = 0
Else
iValue = txtInput.Text
End If
If optMetric = True Then
'FullScale = 60
If iValue > 60 Then
iValue = 60
End If
rad = ((iValue * 4.5 + 135) Mod 360) * 3.1416 / 180
Else
'FullScale = 30
If iValue > 30 Then
iValue = 30
End If
rad = ((iValue * 9 + 135) Mod 360) * 3.1416 / 180
End If
xx2 = Cos(rad) * rNeedle + ccx
yy2 = Sin(rad) * rNeedle + ccy
pbAA.Line (xxi, yyi)-(xx2, yy2), 0
'4b. Draw the centre 'Dot'
.DrawWidth = 6
pbAA.Circle (ccx, ccy), rDot, cc
'5. Print the units of measurement (MPH || km/h) in the lower centre
'of the gauge
pbAA.CurrentX = ccx - 400
pbAA.CurrentY = ccy + 2100
If optMetric = True Then
pbAA.Print "km/h"
Else
pbAA.Print "MPH"
End If
End With
End Sub
Private Sub optImp_Click()
If txtInput.Text = "" Then
txtInput.Text = 0
Else
txtInput.Text = Round(txtInput.Text / 1.609, 1)
End If
Update
End Sub
Private Sub optMetric_Click()
If txtInput.Text = "" Then
txtInput.Text = 0
Else
txtInput.Text = Round(txtInput.Text * 1.609, 1)
End If
Update
End Sub
Private Sub txtInput_Change()
Update
End Sub
'//End Code
Take Care.
Mike
spooboy54 < spooboy54%40yahoo.com">spooboy54
yahoo.com> wrote:
Mike
LOL !! Wasn't sure if I'd hear back from you.
Glad you have fooled around with this.. and if
you copied my original code, by now you've noticed
that the needle sweeps counter-clockwise!!
Anyway, to your current question. I sort of get
your drift, but am not clear as to the issue.. is
it the circle that shows as an ellipse, or is it
the dots?
The reason I asked is that below, you seem to have
added the "7" multiplier only to "yy1", and if I
read your snippet properly, this is only affecting
the placement of the dots, having nothing to do with
the circle. So perhaps you could include a little
more code fragment pertaining to your specific issue.
That said, some other things to consider:
1. Aspect ratio: The Circle Method has as one optional
parameter the aspect ratio. Default is 1 (makes it a circle),
changing it will turn it into an ellipse. I did not include
it in my statement, hence mine drew a circle.
2. ScaleHeight, ScaleWidth: These too can affect the
drawing appearance, turning a circle into an ellipse.
I intentionally set them to the same value to make it a
circle. Did you mess with these?
3. "Any other circle...": could you include a code snippet
that covers these? Something may pop out if I see it.
Spoo
--- In visualbasic6programming%40yahoogroups.com">visualbasic6programming
yahoogroups.com, Michael Malone
<solarquark
...> wrote:
>
> Hi Spoo.
> I've being playing with your PictureBox code below for the last few
days. Cool.
> I have now created my first gauge, with your code as guidance. The
most important problem remains, however. What colour should it be? 
>
> Actually I do have a little problem. This may be some sort of
scaling problem, but I have not been able to discover what it is that
I am doing wrong. The circle draws fine. But any other circle or
circular arrangement draws as an ellipse, 'squished' in the y-axis.
If I alter the code to, for example,
> '3. Put dots at each 45 degrees
> -
> -
> -yy1 = aSin(ii) * rr * 7 + ccy
> -
> -
> Note the '7' above.
> Then the 'dots' draw on the original circle correctly. The same
happens if I try to draw any other circles inside the original (to
create a scale, for instance).
>
> I know I've done something stupid, but I cannot find what this is.
Any ideas?
>