• typesupply

    Thanks. I read through those before posting, but didn’t see anything about using UIBezierPath with canvas. Those posts all seemed to be about working with ui. I used canvas because it’s a static 2D context like the one in DrawBot. Are you suggesting that it would be better to build atop ui instead of canvas? I just looked back through the ui docs and it looks like I could build a custom DrawBotView that presents the output image. (This post is helpful.)

    Thanks again for the help. I’ve done tons of PyObjC work on the Mac and have used Pythonista on my iPad for a few years, but this is the first time I’m trying to do anything *visual *with Pythonista. I’m just trying to get some code development visualization working across devices... :)

    posted in Pythonista read more
  • typesupply

    I’m working on a little Pythonista module that mocks the DrawBot API atop the built in canvasmodule. I need to implement DrawBot’s BezierPath class since I use it a lot. I’ve tried using objc_util.ObjCClass to get a UIBezierPath, draw to it and then paint it, but it doesn’t display. I’ve also tried usingui.Path` With the same results. I’m obviously doing something very wrong. Does anyone have any tips? Any help would be greatly appreciated.

    “””
    Draw a white square containing
    red, green and blue squares.
    “””
    
    import canvas
    import ui
    from objc_util import *
    
    canvas.clear()
    canvas.set_fill_color(1, 1, 1, 1)
    canvas.fill_rect(0, 0, 150, 150)
    
    # UIBezierPath
    canvas.set_fill_color(1, 0, 0, 1)
    path = ObjCClass("UIBezierPath").bezierPath()
    path.moveToPoint_((0, 0))
    path.lineToPoint_((0, 50))
    path.lineToPoint_((50, 50))
    path.lineToPoint_((50, 0))
    path.closePath()
    path.fill()
    
    # ui.Path
    canvas.set_fill_color(0, 1, 0, 1)
    path = ui.Path()
    path.move_to(50, 50)
    path.line_to(50, 100)
    path.line_to(100, 100)
    path.line_to(100, 50)
    path.close()
    path.fill()
    
    # canvas (sanity check)
    canvas.set_fill_color(0, 0, 1, 1)
    canvas.move_to(100, 100)
    canvas.add_line(100, 150)
    canvas.add_line(150, 150)
    canvas.add_line(150, 100)
    canvas.add_line(100, 100)
    canvas.close_path()
    canvas.fill_path()
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!