Group Details Private


  • RE: Script to Standalone app

    If you use a path in font(filePath) then the path is relative to the current directory (which is not always the the directory of the python file)

    DrawBot the app set the current directory to the .py file directory. When used as module this does not happen.

    So either set the a correct current directory or get a absolute path from the .py file: os.path.join(os.path.basename(__file__), "font.otf")

    posted in Code snippets
  • RE: Rounded Rectangle

    cool way to make a rounded rect!

    there are already a roundedRect example in the repository: see

    I would encourage you to make a python package out of your helper tools that you import when you needed it...

    # a separate file with the name ""
    def roundedRect(...):
        # draw your stuff here
    # an other file in the same directory
    #  name of the file/module  name of the function 
    from roundedRect import roundedRect
    # call it

    hope this makes sense!

    posted in Code snippets
  • RE: Script to Standalone app

    that is way to complex 🙂

    Variable works fine with the UI of drawBot... dont use it outside a drawBot document 😉

    You will have more control when you build it with vanilla and use this in a drawBot packages.

    import vanilla
    class MyController:
        def __init__(self):
            self.w = vanilla.Window((150, 40), "My Tool Name")
            self.w.slider = vanilla.Slider((10, 10, -10, 22), callback=self.sliderCallback)
        def sliderCallback(self, sender):        
            x = sender.get()
            fill(random(), random(), random())
            oval(x, 0, 1000, 1000)

    this script wrapped in a .drawBot package

    posted in Code snippets
  • RE: Script to Standalone app

    this should work!


    You can open the debugger in drawBot by hitten alt with the help menu open.

    posted in Code snippets
  • RE: Script to Standalone app

    If drawBot is installed as a module you can access it anywhere!

    If Variable(..) is a key thing in your script, use a drawBot package, where you can set a main script that gets executed when the file is opened in

    posted in Code snippets
  • RE: Change the value of a bool with (arrow) keys

    yes, thanks @jo

    possible with cmd + arrows keys or cmd + click when ever True or False is selected

    posted in Feature Requests
  • RE: Script to Standalone app

    Some parts of drawBots api don't work automatically outside the application, mainly parts where an UI is involved.

    But first why building an app?

    I would recommend UI parts to build separately. Build a window with vanilla, add some sliders and callback whenever that slider will change.

    DrawBot has a drawBot package, so drawBot code can be shared without looking a complex script folder structure:

    posted in Code snippets
  • RE: QR code with type

    expanding Gustavo's example:

    import colorsys
    path = bytes('', 'utf-8')
    w, h = 31, 31
    s = 10
    size(w*s, h*s)
    img = ImageObject()
    img.QRCodeGenerator((w, h), path, 'Q')
    iw, ih = img.size()
    t = ""
    for y in reversed(range(int(ih))):
        for x in range(int(iw)):
            r, g, b, a = imagePixelColor(img, (x, y))
            _, l, _ = colorsys.rgb_to_hls(r, g, b)
            if l < 0.51:
                rect(x*s, y*s, s, s)
                t += "W"
                t += " "
        t += "\n"
    font("Menlo", 16)
    textBox(t, (0, 0, width(), height()))

    and the corners are always the same 🙂

    posted in General Discussion
  • RE: Forced justified

    DrawBot is using CoreText to layout text. This is the same engine as, and it seems this is also not possible there...

    posted in General Discussion
  • RE: FontTools, probably a simple question

    this works...

    from fontTools.misc.bezierTools import calcCubicArcLength
    pt1 = 100, 100
    pt2 = 200, 100
    pt3 = 400, 150
    pt4 = 400, 400
    l = calcCubicArcLength(pt1, pt2, pt3, pt4)
    path = BezierPath()
    path.curveTo(pt2, pt3, pt4)
    text(str(l), pt3)
    posted in General Discussion