Thank you so much for the example, not only for the fact you got the basic functionality there, but also for the comments and tips. I will study it hard
I can certainly take it from here,
It's mostly a learning exercise, but if it turns out to be useful I'll see about making it robust enough for sharing.
Side note about docs: I think that if you print help it should not print a joke (or broken) link otherwise it leads you to believe you're missing important information that is no longer accessible, perhaps it can be updated?
It's a similar story for the "starting with mojo" link on the homepage, I can't count the amount of times I clicked on that thinking that's where I will find answers and there's nothing there. Both examples undermine the authority of the docs that do exist, leaving you wondering if they are incomplete.
I found a way to speed up the brute force approach though. If you can use external Python modules:
from scipy import spatial
tree = spatial.KDTree(t_list) # t_list is a list of pre-calculated point coordinate tuples on the cubic curve
distance, index = tree.query(pt) # pt is the given point coordinate tuple
t_for_pt = float(index) / (len(tree.data) - 1)
t_list must be constructed in a way that the first entry is for t = 0 and the last entry for t = 1. It doesn't matter how many points for increments of t you calculate, as long as the index in t_list is proportional to t. Smaller increments of t increase the precision of the result, but the list takes longer to build.
I have this... But it is buggy. See if you scroll. If you change a glyph the factory doest work, only after scrolling/clicking on the overview.. Here I need a bit help
from vanilla import *
from defconAppKit.controls.glyphCollectionView import *
from defconAppKit.windows.baseWindow import BaseWindowController
from mojo.UI import SetCurrentGlyphByName
def __init__(self, glyphs):
self.w = Window((900,600), '')
self.w.collectionView = GlyphCollectionView((15, 15, -15, -65), doubleClickCallback=self.double, cellRepresentationName='doodle.GlyphCell')
title = f.info.familyName +' - '+ f.info.styleName+', '+ str(CurrentGlyph())
def double(self, sender):
order = f.lib.get('public.glyphOrder')
f = CurrentFont()
g = CurrentGlyph()
glyphs = 
for g in f.lib.get('public.glyphOrder'):
there is Glyph.selection.Changed notification
also don't forget to remove the observer when your are done...
self.g = CurrentGlyph()
self.g.addObserver(self, "selectionChanged", "Glyph.selectionChanged")
def selectionChanged(self, notification):
glyph = notification.object
for anchor in glyph.anchors: