Glyphs PatternCreator

For some specific purposes (and thereafter for fun) I wrote the PatternCreator for Glyphs.
When doing so, two questions arose and I can’t figure out an answer:

  1. Creating a perfect circle happens when the handles are 55% between zero and the intersection-point of the handles. (And a little bit % more I see when drawing a circle with the Circle tool in Glyphs.)
    What is the logic, where can I find information about how the curve is related to the position of the handles? I would like to know how the curve is calculated.

  2. If I want to fill in an existing letterform with a pattern, is there still no other option than the one I found on How do I intersect two shapes? ? Because it would be a lot of work to get this ready. For example the glyph ‘o’: make a pattern, make intersections, select all parts of the pattern that lies outside the original shape, then doing the same for the inner circle of the ‘o’, while making sure that pattern-parts which have no intersections with the ‘o’ at all are also erased…

If there is no other option I will do it this way, but how is the code of Glyphs doing this when the user presses the button ‘intersect?’

Thanks in advance for advice

The current version of the Script is on

  1. Here is some code that might help:

patternPaths = NSMutableArray.array()

# add some paths

Operator = NSClassFromString("GSPathOperator").alloc().init()
Operator.subtractPaths_from_error_(originialPaths, patternPaths, None)

# now patternPaths contains the result. 

The algorithm is not bulletproof yet. It works better if you run it with each part of the pattern

1 Like

I will give it a try

  1. Just mentioning random fact I know about circle and Bezier. Circle in bezier is, no matter how hard you try, is only an approximation (0.027% different at biggest, and tends to be slightly larger. Very close, but mathematically impossible nonetheless). And the ideal handle length is approximately 55.1915024494…%, so it’s okay to be tad longer sometimes.

Source: Approximate a circle with cubic Bézier curves

1 Like

Ha, I got 55.1784%

Source: Don Lancaster: Approximating a Circle or an Ellipse Using Four Bezier Cubic Splines

In fact I got other values too, like 55.21…%.

Thanks to both :slight_smile:
A nice to know detail

I seem to remember other approximations with 56 and 57 point something. But since I cannot find anything about it anymore, perhaps I am remembering wrong. But it is to be expected that you get different results depending on what exactly you want to approximate: area, circumference, number of points touching the circle, approximate it from outside or inside, etc.

How about 55.22847498%? Source: G. Adam Stanislav, Drawing a circle with Bézier Curves. And I just saw that Luc Devroye collected lots of links on Bézier theory.

If you draw a circle with 200 units of diameter in glyphs each BCP have 55 units.

Glyphs uses 55.229%.