[Gambas-user] painting graph to image continuously

wally wally at ...2037...
Wed Dec 15 15:03:30 CET 2010


I'm trying to paint a continuous graph to an image, the image should grow
in width as needed. I thought the following code might do the job but it 
generates not a clear graph after first Image.Resize. (see attachment) 

How looks a better coding to do this job ?  
thanks wally

code:  GB3
Public Sub Button4_Click()
  Dim t As Integer
  Dim y As Integer
  
  myImage1 = New Image(210, 128, Color.RGB(255, 255, 223))
 
  For t = 0 To 2000 
    If (t Mod 25 = 0) Then
      y = CInt(Rnd(0, 128))
    Endif
  
    If t > myImage1.W Then
      myImage1.Resize(myImage1.w + 10, myImage1.H)
      PictureBox1.w += 10
    Endif
  
    
   Paint.Begin(myImage1)
     Paint.Brush = Paint.Color(Color.RGB(0, 0, 0))
     Paint.LineWidth = 1
     Paint.MoveTo(last_t, last_y)
     Paint.LineTo(t, y)
     Paint.Stroke
   Paint.End
   
   Wait 0.05
   
   PictureBox1.H = myImage1.H
   PictureBox1.Picture = myImage1.Picture
   ScrollView1.EnsureVisible(t, 64, 50, 50)
  
   last_t = t
   last_y = y
  Next
End

-------------- next part --------------
A non-text attachment was scrubbed...
Name: screenshot_7.png
Type: image/png
Size: 11509 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20101215/2728dc17/attachment.png>


More information about the User mailing list