' Cool Gauge provides an easy vay of showing data like audio EQ
' Im using QDXTimer at Max Speed Of Course that eats CPU Cicles !!!
' Should use Asaembler ??? or buy a good P III ?

'There are Some things you might whant to know 
'1° This timers Show Random Data stored into an array called A
'2° The Main Function That shows The Info has some code commented 
'You Might Whant to reuse it or not it is a good example for starting whit canvas !
'3° For tasting pruporses im overriding some things that can cause errors
'4° This code is absoulutly FREE !!! 
'5° for any thing send an e-mail to benjamin_maggi@uol.com.ar
'Sorry for my bad English !

DIM Canvas AS QCanvas

DIM Form AS QForm
DIM Timer1 AS QDXTimer
DIM Font AS QFont
'General Use variables
DIM Y AS INTEGER
Dim X as Integer
Dim mPicPWidth As Integer
Dim mPicPHeight As Integer
Dim mPicHeight As Integer
Dim mPicHandle As Long
Dim mBackColor As Long
DIM Flag as Integer

SUB Resize
  Canvas.Height = Form.ClientHeight
  Canvas.Width = Form.ClientWidth
END SUB

DECLARE SUB OnMouseMove2 (X As Integer, Y2 As Integer, Shift As Integer)
Sub Paint(Value As Integer, X2 as Integer, Y2 as Integer, Pic as QCANVAS, Col as Long)

    DIM I AS INTEGER
    DIM J AS INTEGER

   'Cleaning Blak Line ! (Replace old data whit a blak Line )
     Pic.Line (X2, 0, X2,(200 - Value), RGB(0,0,0))

    Pic.Line (X2,(Y2 + mOldVal),X2, (Y2 - Value), Col)
    
   ' De Rojo a verde (degrade from red to green)
   'Canvas.Line (X2, (200 - (value - 20)),X2,(200 - Value), RGB(250,25,5))
   'Canvas.Line (X2, (200 - (value - 18)),X2,(200 - Value), RGB(225,50,5))
   'Canvas.Line (X2, (200 - (value - 16)),X2,(200 - Value), RGB(200,75,5))
   'Canvas.Line (X2, (200 - (value - 14)),X2,(200 - Value), RGB(175,100,5))
   'Canvas.Line (X2, (200 - (value - 12)),X2,(200 - Value), RGB(150,125,5))
   'Canvas.Line (X2, (200 - (value - 10)),X2,(200 - Value), RGB(125,150,5))
   'Canvas.Line (X2, (200 - (value - 8)),X2,(200 - Value), RGB(100,175,5))
   'Canvas.Line (X2, (200 - (value - 6)),X2,(200 - Value), RGB(75,200,5))
   'Canvas.Line (X2, (200 - (value - 4)),X2,(200 - Value), RGB(50,225,5))
   'Canvas.Line (X2, (200 - (value - 2)),X2,(200 - Value), RGB(25,250,5))

'Another Degrade !    
    'Pic.Line (X2, (Y2 - (value - 20)),X2,(Y2 - Value), RGB(250,225,0))
    'Pic.Line (X2, (Y2 - (value - 18)),X2,(Y2 - Value), RGB(250,200,0))
    'Pic.Line (X2, (Y2 - (value - 16)),X2,(Y2 - Value), RGB(250,175,0))
    'Pic.Line (X2, (Y2 - (value - 14)),X2,(Y2 - Value), RGB(250,150,0))
    'Pic.Line (X2, (Y2 - (value - 12)),X2,(Y2 - Value), RGB(250,125,0))
    'Pic.Line (X2, (Y2 - (value - 10)),X2,(Y2 - Value), RGB(250,100,0))
    'Pic.Line (X2, (Y2 - (value - 8)),X2,(Y2 - Value), RGB(250,75,0))
    'Pic.Line (X2, (Y2 - (value - 6)),X2,(Y2 - Value), RGB(250,50,0))
    'Pic.Line (X2, (Y2 - (value - 4)),X2,(Y2 - Value), RGB(250,25,0))
    'Pic.Line (X2, (Y2 - (value - 2)),X2,(Y2 - Value), RGB(250,0,0))
    
'Easy Degrade (Uses CPU)
'Kind Like a 3D effect cool !!
    'J = 0'225
    'For i = 15 to 1 STEP - 1
    'Pic.Line (X2, (Y2 - (Value + I*2)),X2,(Y2 - Value), RGB(0,j,0))
    'j = j + 50
    'Next I
        
    mOldVal = value
    
End Sub

SUB TimerOver
  Dim i As Integer
  Dim j as Integer
  DIM A(400) As Integer

  Dim B as Long
  B = 1/2
  RANDOMIZE
  'Y = Y + 1            '' Pixel by pixel!
  'if Flag = 1 Then 
  ' Flag = 2
  'End If
  X = X + 1
'This shows some Hor and Vert Lines on the Canvas
'Just to make a rule
  if Flag = 3 Then 
  For i = 0 to 200 
  Canvas.Line(0,i * 10,400,i * 10, RGB(77,77,77))
  Next i
  For i = 0 to 400
  Canvas.Line(i * 10,0,i * 10,200, RGB(77,77,77))
  Next i
  Flag = 1
  End If
  If Flag = 1 Then Y = Y + 1
  If Flag = 2 Then Y = Y - 1
'Fill The Array whit Random Data 
'You should fill it whit your oun Data !
  For i = 1 to 200
    A(i) = 100 - RND(Y + i/5)
  Next i
  
  If Y = 25 then Flag = 2
  If Y = 0 Then Flag = 1
  'Canvas.Line(X1,Y1,X2,Y2,255) (in case you fogot the func params)
 'Step By step Fill The canvas 
  For i = 1 to 200
    call Paint(A(i),i*2,200,Canvas,RGB(255,i*1.27,0 )) '1.3 works fine 
                                                    'with this but i dont 
                                                     'Knows what means help me !
  Next i
  
END SUB

Form.Width = 400
Form.Height = 200
Form.Center
Form.Color = 0
Form.Caption = "Gauge Control"


Canvas.Parent = Form
Canvas.Color = 0
'Not shoure of random Data try This 
'Canvas.OnMouseMove = OnMouseMove2


Timer1.Interval = 0   'This can freeze your CPU 
                      'im using a AMD K6-2 533 and it's kind Slow
                      'Painting whit degrades could be a bad idea on slow systems
Timer1.Enabled = 1   
Timer1.OnTimer = TimerOver
Flag = 1              'Im painting some rules ...
Form.Onresize = Resize
Form.ShowModal


Sub OnMouseMove2 (X As Integer, Y2 As Integer, Shift As Integer)
    'Canvas.Pset(X,Y,RGB(255,255,255)) 'Try to make a paint ???
    Y = X
    If Shift <> 0 then
    showmessage str$(Shift)
    End If
end Sub