示例#1
0
# robothon 2009
# set guidelines on the average x, y of all selected points
# in the current glyph.
# useful for working on symetric glyphs.

from robofab.world import CurrentGlyph

g = CurrentGlyph()

# remove all old guides first
g.clearHGuides()
g.clearVGuides()

# this is where we'll be storing some data
guides = {}
average = {}

# iterate through the points, find the selected points
# and their associated off-curve points.
for c in g:
    for pt in c.bPoints:
        if pt.selected:
            average[(pt.anchor[0], pt.anchor[1])] = 1
            guides[(pt.anchor[0], pt.anchor[1])] = 1
            guides[(pt.anchor[0] + pt.bcpIn[0],
                    pt.anchor[1] + pt.bcpIn[1])] = 1
            guides[(pt.anchor[0] + pt.bcpOut[0],
                    pt.anchor[1] + pt.bcpOut[1])] = 1

# calculate an average position
x = None