I've been using DrawBot to generate diagrams—specifically, Boolean diagrams of categories with fuzzy boundaries—and I would love to see both linear and radial gradients incorporate an alpha channel.
Posts made by MauriceMeilleur
RE: Editing BezierPaths directly
I thought after I posted that pens would be part of a more elegant solution—my problem reminded me of some things Just has shown me, and I recall pens coming up in that conversation.
The fix I did find was to create a function that creates and returns a new path from the uncorrected path contour by contour and segment by segment, correcting points as needed by rounding to the nearest implied-grid increment. But now that classes are out I'll take the time to learn about pens (finally).
I'd still like to figure out why I was having the problem in the first place. At 1000pt the glyphs in Kast, my font I've been working with, are all exactly 692pt wide. With the proper linespacing and every other line offset 346pt (the width of the <space> glyph) all the points in adjacent glyphs horizontally and vertically should match exactly to allow me to combine their paths seamlessly.
Looking at the errors—maybe I'll put the analyses up in another post, I saved my test code—I felt like there was something about the formatted string that was introducing systematic misalignment, and removeOverlap() was also doing some math that threw off some points in the combined paths.
Editing BezierPaths directly
For reasons I can explain in detail if needed, I'd like to edit the oncurve points of a BezierPath before drawing the path, checking each point in turn to make sure its coordinates fall on an implied alignment grid and correcting it as needed.
Two methods that apparently don't work are:
for pt in path.onCurvePoints: if test(pt) == Fail or test(pt) == Fail: pt = (correctedCoordinate, correctedCoordinate)
for pt in range(len(path.onCurvePoints)): if test(path.onCurvePoints[pt]) == Fail or test(path.onCurvePoints[pt]) == Fail: path.onCurvePoints[pt] = (correctedCoordinate, correctedCoordinate)
RE: Size of text box doesn't correspond exactly to fontSize
Good to know, thanks. But that means that default linespacing = fontSize + 1?
Size of text box doesn't correspond exactly to fontSize
,Here's something interesting I found while writing code to generate the dimensions of a canvas based on the amount and size of the text I want to set in a square-ish field on the canvas.
fontFamily = 'kast_4_a' fontStyle = 'top_0' fSize = 1000 test_string = FormattedString() test_string.append('a', fontSize = fSize, font = fontFamily + '-%s' %fontStyle) print(test_string.size())
yields the following:
<NSSize width=692.0 height=1001.0>
I can confirm that DrawBot's size() returns a height of any fontSize + 1.
I was hoping to use the size of the text box to calculate the height of the canvas, but now I have to adjust that it seems. What's happening here?
RE: Problems with cv2? Alternative for resizing saved images on the fly?
That's a nice workaround, thanks! I didn't consider the resolution parameter since I was thinking in terms of the absolute size of the image in pixels only. Maybe I'll put in a feature request, since pixel dimensions feels like a more intuitive way to characterize output.
Problems with cv2? Alternative for resizing saved images on the fly?
Since DB's saveImage() doesn't allow me to resize images as I generate them (and is that right?), I was hoping to use the openCV-python library. But even after installing with pip3.7 and no --user flag I can't get DB to import cv2. Has anyone else run into this problem or gotten openCV to work in DB? Or does anyone have another suggestion for adjusting the size of saved images?
RE: Text to outlines > find objects with similar fill > Boolean operations?
@frederik But I figured it out! Obviously the fill/stroke properties from the formatted strings won't find their way into the Bezier paths, but I can just add them to the paths directly. (I guess I could just use text, but I want some flexibility in the code for when Kast is a variable font.) Just have to write the code to clean/chop up strings into even lines and size the text to position/size the lines to make fields.
A really useful Maurice-bot would tell me to do the work first and then post just to share the results and the code.