[Gambas-user] painting graph to image continuously
Benoît Minisini
gambas at ...1...
Wed Dec 15 15:10:46 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
When you create an image, or enlarge it, the contents is never initialized by
default. You must paint the background of the new part first.
Regards,
--
Benoît Minisini
More information about the User
mailing list