[quote=336919:@Emile Schwarz]I just realized the error is in the impleùmentatio: yiou use Refresh in the loops button. That is what tooks so long.
Place an offscreen Picture, set the code to it and in the end, draw that Offscreen Picture in Canvas2.Paint.
In fact, tell what you really want to do: my advice above can be useless in some cases
ERRORS BELOW. When I changed i, I in the last line to 0,0 it works.
I cannot run your modified code below (xojo 2017r1.1):
This item does not exists.
No yellow hint given.
Canvas2:
[code]Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
Dim u As Integer = 100
Dim p As New Picture(1, 1)
For i As Integer = 1 To u
p.RGBSurface.Pixel(0, 0) = &cff0000
Next
g.DrawPicture p, i, i
End Sub[/code][/quote]
I simply want an easy and performant alternative for Graphics.Pixel (as this is deprecated).
The loops and Canvas.Refresh and methods used in the sample project were only for testing the performance of alternative techniques.
Even this is two times slower than simply using Graphics.Pixel:
[code]
Dim u As Integer = 100
g.ForeColor = &cff0000
For i As Integer = 1 To u
g.fillrect i, i, 1, 1
Next[/code]
So what do you suggest is the best way to draw let’s say 100 pixels anywhere on a canvas?
If possible it should be as performant as Graphics.Pixel.