I'm looking to not print :
*** DrawBot warning: [...] ***
I would like to translate a BezierPath, without changing it's bounds.
Here is code where you can see my problem.
newPage(2000,2000) # Grey Rectangle path0 = BezierPath() path0.rect(1000,10,200,1990) with savedState(): fill(0, 0.1) drawPath(path0) # Green Rectangle path1 = BezierPath() path1.text("1", fontSize=200) with savedState(): fill(0,1,0) rect(*path1.bounds()) drawPath(path1) # Red Rectangle path2 = BezierPath() path2.text("2", fontSize=200, offset=(200,300)) with savedState(): fill(1,0,0) rect(*path2.bounds()) drawPath(path2) # Yellow Rectangle path3 = BezierPath() path3.text("3", fontSize=200) path3.translate(100,800) with savedState(): fill(1,1,0) rect(*path3.bounds()) drawPath(path3) # Magenta Rectangle translate(900,800) path4 = BezierPath() path4.text("4", fontSize=200) with savedState(): fill(1,0,1) rect(*path4.bounds()) drawPath(path4)
I tested 3 solution:
use offset in path.text
Change BezierPath bounds
Change BezierPath bounds
Don't change BezierPath bounds
But this is annoying, because I don't want to translate all my canvas just for that.
So what is the solution ?
I recently uploaded snippets to add DrawBot auto-completion in VSCode, Atom and SublimeText.
You can access them from my GitHub Repo:
Snippet do draw rectangle with rounded corner:
def rectRounded(x,y,w,h,radius): path = BezierPath() sR=0.5*radius w=w-radius h=h-radius path.rect(x,y+sR,w+radius,h) path.rect(x+sR,y,w,h+radius) path.oval(x,y,radius,radius) path.oval(x+w,y,radius,radius) path.oval(x,y+h,radius,radius) path.oval(x+w,y+h,radius,radius) path.removeOverlap() drawPath(path)
It is possible to manually add it in drawBot module ?
I would like to ask users to select a folder and get his path. Here with my code, a window opens to choose the file but nothing happen after. Like if the script stop after the 3rd line.
from tkinter import Tk from tkinter.filedialog import askdirectory path = askdirectory(title='Select Folder') # shows dialog box and return the path print(path)
No error message appears.
I put the complete tkinter module in the folder which contain the script.
I'm working on a script for Glyphs to build a Character set with Drawbot Extension. I'm using the Glyph API to extract the BezierPath of my letters.
I would like to set the x,y position of the Path without using translate
Here is my code :
from GlyphsApp import * f = Glyphs.font # frontmost font m = f.selectedFontMaster # active master paperSize = 'A4Landscape' newPage(paperSize) scale (0.2, 0.2) path = f.glyphs["A"].layers[m.id].completeBezierPath drawPath(path)
I started to write a Drawbot script to build automatic proofing files for my fonts.
I would like to change the tracking of a textBox, but there is a problem.
When I use a variable as txt, tracking doesn't work (example bellow)
textBox(FormattedString(txt=Text_sample, fontSize=50, tracking=200, font='Helvetica'), (10, 10, 400, 400)
But If I replace the variable Text_sample by a real text with '', it's work.
textBox(FormattedString(txt='Test', fontSize=50, tracking=200, font='Helvetica'), (10, 10, 400, 400)
How can I apply tracking to a textBox ?
Or If it's not possible does it exist an alternative ?