• WillW68

    I copied and pasted your code into a new script, and get the same result - when I lift my finger off at the end of a stroke, the alpha value of the whole stroke changes (gets lighter).

    I am running the latest version of Pythonista (3.2) using python 3.6 on a 10.5” iPad Pro with iOS 11.2

    posted in Pythonista read more
  • WillW68

    I have modified the Sketch.py code to draw a succession of ovals instead of using path.stroke(), with the intention of using the pencil pressure to change the alpha at different points along the path. In the code below I have kept it constant for simplicity. But the alpha value does not seem to be captured correctly in ctx.get_image(), causing it to change when path_action() is called at the end of the path. Just add the code below to the Sketch.py example, and change the definition in touch_began() to self.path = MyPath() to see the problem when you lift the pencil/finger at the end of the stroke.

    import math
    def distanceBetween(point1, point2):
      return math.sqrt((point2[0] - point1[0])**2 + (point2[1] - point1[1])**2)
    def angleBetween(point1, point2):
      return math.atan2( point2[0] - point1[0], point2[1] - point1[1] )
    class MyPath():
        def move_to(self,x,y):
            self.path = [(x,y)]
        def line_to(self,x,y):
        def stroke(self):
            w = 20
            lastPoint = self.path[0]
            for i in range(1,len(self.path)):
                currentPoint = self.path[i]
                dist = distanceBetween(lastPoint, currentPoint)
                angle = angleBetween(lastPoint, currentPoint)
                for j in range(int(dist)):
                    x = lastPoint[0] + (math.sin(angle) * j)
                    y = lastPoint[1] + (math.cos(angle) * j)
                    circle = ui.Path.oval(x, y, w, w)
                lastPoint = currentPoint

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!