Problem with path closing



  • Hi everyone:

    I'm making shapes using the arc tools and I'm having a problem in the intersection of two points:

    Captura de Pantalla 2020-02-24 a la(s) 10.35.30.png

    This is the code I'm using, and the reason I didn't use the oval tool is that I want to make random movements on every arc.

    def shapePage(o=0, wd=1000, hg=1000, sWd=10, positive=True, cur = True, double=False):
        hWd = wd / 2
        hHg = hg / 2
        hsWd = sWd / 2
        def canvas():
            newPage(wd, hg)
            if positive is True:
                fill(1)
            if positive is False:
                fill(0)
            rect(o, o, wd, hg)
        def blackShape():
            path = BezierPath()
            fill(None)
            if positive is True:
                stroke(0)
            if positive is False:
                stroke(1)
            strokeWidth(sWd)
            def shape(cur, radius=hWd):
                points = [
                    [hWd, o + hsWd],
                    [wd - hsWd, o + hsWd],
                    [wd - hsWd, hHg],
                    [wd - hsWd, hg - hsWd],
                    [hWd, hg - hsWd],
                    [o + hsWd, hg - hsWd],
                    [o + hsWd, hHg],
                    [o + hsWd, o + hsWd],
                    [hWd, hHg]
                    ]
                while radius >= sWd * 2:
                    newsWd=sWd * 2  
                    if cur is True:
                        path.moveTo(points[0])
                        path.arcTo(points[1], points[2], radius)
                        path.arcTo(points[3], points[4], radius)
                        path.arcTo(points[5], points[6], radius)
                        path.arcTo(points[7], points[0], radius)
                    if cur is False:
                        path.moveTo(points[0])
                        path.lineTo(points[1])
                        path.lineTo(points[2])
                        path.lineTo(points[3])
                        path.lineTo(points[4])
                        path.lineTo(points[5])
                        path.lineTo(points[6])
                        path.lineTo(points[7])
                        path.lineTo(points[0])
                    lineCap("butt")
                    #lineJoin("miter")
                    closePath()
                    drawPath(path=path)
                    for point in points:
                        if point[0] < hWd:
                            point[0] += newsWd
                        if point[0] > hWd:
                            point[0] -= newsWd
                        if point[0] == hWd:
                            point[0] = point[0]
                        if point[1] < hHg:
                            point[1] += newsWd
                        if point[1] > hHg:
                            point[1] -= newsWd
                        if point[1] == hHg:
                            point[1] = point[1]
                    radius -= newsWd
            shape(cur)
            if double is True:
                shape(not cur)
        canvas()
        blackShape()
    

  • admin

    every arc is separate contours in a path, what you see is the lineCap (see)



  • Thank you @frederik ! I was wondering if there's a way to access to the curves of an oval(x, y, w, h)



  • hello @eduairet,

    you can draw an oval using a BezierPath, and then access its contours and points:

    B = BezierPath()
    B.oval(100, 100, 800, 800)
    print(B.contours)
    print(B.points)
    print(B.onCurvePoints)
    print(B.offCurvePoints)
    

    cheers!



  • @gferreira 🤘 great!!!! thank you very much.


Log in to reply