Drawing with Eto

Can someone demonstrate how the Graphics classes work in Eto with python? I can never get the DrawLine() parameters correct, no matter what I input. Can the self.myLine then just be added to a DynamicLayout() or is there another object to handle it?

import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
import rhinoscriptsyntax as rs

class drawShapes(forms.Dialog[bool]):
    def __init__(self):
        self.MinimumSize = drawing.Size(200, 200)
    def addLine(self):
        self.pt0 = drawing.PointF(0,0)
        self.pt1 = drawing.PointF(50,50)
        self.color1 = drawing.Colors.Blue
        self.myLine = drawing.Graphics.DrawLine(self.color1, self.pt0, self.pt1)

dialog = drawShapes()
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)

Hi @Tim_Williams,

you might obtain an instance of the Graphics object either from the paint event args of a drawable object or create one from a bitmap. I’ve used the latter.

ETO_GraphicsDrawingTest.py (1.3 KB)

To get the parameters right for DrawLine() see here



Great example! You clearly are a skilled artist :grinning:.