Boolean and Rounded Corners



  • I have a code that generates a pattern of single rectangles according to a text input.

    def letter_a():
    
        fill(0,0,0)
        rect (2*x,2*y, rectWidth, rectHeight)
        rect (3*x,2*y, rectWidth, rectHeight)
        rect (4*x,1*y, rectWidth, rectHeight)
    
        return letterWidth
            
    def letter_b():
        fill(0,0,0)
        rect (2*x,2*y, rectWidth, rectHeight)
        rect (3*x,2*y, rectWidth, rectHeight)
        rect (3*x,1*y, rectWidth, rectHeight)
    
        return letterWidth  
        
    #etc.
    
    def drawLetter(func):
        with savedState():
            rotate(letterTilt, center=(letterWidth/2, 200))
            width = func()
        translate(width, 0)
    
    textInput = "abcd\nefgh"
    
    
    save()
    for char in textInput:
        if char == "\n":
            restore()
            translate(0, -y*2)
            save()
        else:
            func = characterMap.get(char, draw_notdef)
            drawLetter(func)
     
    saveImage("~/Desktop/Cyborg-Alphabet.svg")   
    
    

    This is the pattern it produces:
    https://ibb.co/N94VFnH (sorry, the option to import an image doesn't seem to work)

    I would like to 'stylise' the resulting pattern, with the equivalent of a Pathfinder in Illustrator and a rounded corner effect so it looks like that:
    https://ibb.co/xhTwP19

    Is there a way to do this in Drawbot?


  • admin

    he Lara!

    Nice to see you continuing your drawBots!!

    x, y = 300, 300
    s = 100
    # draw your rects as ovals
    oval(x, y, s, s)
    oval(x + s, y, s, s)
    oval(x + s, y + s, s, s)
    # build up connections with rects
    rect(x + s/2, y, s, s)
    rect(x + s, y + s/2, s, s)
    

    b8a0cb31-bcc4-4a19-9aa7-4c7635d8b202-image.png


Log in to reply