typemytype / booleanOperations

Boolean operations on paths
MIT License
39 stars 18 forks source link

why not using same method names and operators of built-in sets? #33

Closed anthrotype closed 8 years ago

anthrotype commented 8 years ago

Python built-in sets use the same names for three out of four of the booleanOperations methods: union, difference, intersection. Only for symmetrical_difference we use a different name, xor.

https://docs.python.org/3/library/stdtypes.html#set

I propose we make xor an alias of symmetrical_difference, for consistency with the built-in Python set API.

Similarly, the BooleanGlyph overrides the binary arithmetic operators, using the same symbols as those used by Python sets -- except for difference, where we use modulo % whereas sets use minus -.

Again, for consistency, I believe we should add __sub__ as an alias to __mod__, so we can do BooleanGlyph(glyph1) - BooleanGlyph(glyph2), while maintaining compatibility with the old % operator.

typemytype commented 8 years ago

The methods are carefully taken with glyph math in mind. plus, minus, multiply and divide are 'taken' or used to perform glyph math; calculating with point coordinates. BooleanOperations should be clearly something else so no __sub__. This is handy for subclassing both from a GlyphMath object as from BooleanGlyph object.

The rest of the api follows the same logic as built-in sets.

anthrotype commented 8 years ago

I don't know what you mean by "glyph math". I am familiar with the sets interface, and I thought the operations on sets could be assimilated with what we do on contours in booleanOperations. I don't really mind, actually.

anthrotype commented 8 years ago

Thanks for the clarification!

typemytype commented 8 years ago

see https://github.com/typesupply/fontMath/blob/master/Lib/fontMath/mathGlyph.py#L61