justvanrossum / drawbot-skia

A cross-platform subset of the DrawBot drawing API, using Skia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

functions not possible?

joachimheintz opened this issue · comments

i cannot get functions to use, for instance:

def myline(x1,y1,x2,y2):
line((x1,x2),(y1,y2))

size(700,250)
myline(100,100,200,50)

no error, but also no output.

i also tried different variants, like:

def myline(x1,y1,x2,y2):
path = BezierPath()
path.line((x1,y1),(x2,y2))
path.closePath()
drawPath(path)

am i missing anything, or is this simply not supposed to work?

You have to set the stroke color: for example stroke(1, 0, 0)

this does not change it for me. for instance, i have put the tests/apitests/arc.py example in a function like this:

def myArc():
path = BezierPath()
path.moveTo((100, 100))
path.arc((100, 100), 80, 230, 170, False)
path.arc((100, 100), 60, 30, 120, True)
path.closePath()
stroke(0)
fill(None)
strokeWidth(4)
drawPath(path)

but when i call it i get no output:

size(700,250)
myArc()

How do you run the script?

It works for me if I call it like this:

$ drawbot test.py test.png
def myArc():
    path = BezierPath()
    path.moveTo((100, 100))
    path.arc((100, 100), 80, 230, 170, False)
    path.arc((100, 100), 60, 30, 120, True)
    path.closePath()
    stroke(0)
    fill(None)
    strokeWidth(4)
    drawPath(path)

# but when i call it i get no output:

size(700,250)
myArc()

ah yes now i see that it is a problem of my workflow. of course i have to write the function in the file, too, rather than just having it in my python environment ...
thanks for the quick help!