I am trying to create color swatches for each layer. I will use them in nodes of a TreeGridView. For some reason code below takes few seconds to execute. Slowdown is at the Clear() or FillRectangle() methods. Any idea why? Is there a better way to do this?
import Eto.Drawing as drawing import Eto.Forms as forms def Swatch(color=(250, 200, 100)): size = drawing.Size(10, 10) * int(forms.Screen.PrimaryScreen.LogicalPixelSize) bitmap = drawing.Bitmap(size, drawing.PixelFormat.Format32bppRgb) with drawing.Graphics(bitmap) as g: #g.Clear(drawing.Color.FromArgb(color, color, color)) #even slower rec = drawing.Rectangle(drawing.Point(1, 1), drawing.Size(8, 8)) col = drawing.Color.FromArgb(color, color, color) g.FillRectangle(col, rec) return bitmap for i in range(50): Swatch()