Is it technically possible?
You can record the node’s position, remove it, then compare the distance between the path and the recorded position to a threshold you define:
threshold = 3.6
path = Glyphs.selectedLayers[0].paths[0]
n = path.nodeAtIndex_(8)
pos = n.position
path.removeNodeCheckKeepShape_normalizeHandles_(n, True)
if path.distanceFromPoint_(pos) < threshold:
print("Yes.")
This sample should get you started.
There is no algorithm that does it all automatic. You can use the above code to go through all nodes, remove one, check how much the path changed …
Must the comparison of the shapes of two curves before and after a node is deleted be done by a person? Can’t software measure the similarity between two vector curves?
This is the opinion of AI:
Comparing the shapes of two curves before and after deleting a node doesn’t necessarily have to be done manually. Software can indeed measure the similarity between two vector curves. Modern graphics processing and computer vision technologies are quite advanced, and there are many software tools and algorithms available for analyzing and comparing the shapes of vector curves. Here are some common methods:
1. Geometric Feature Comparison
- Curvature Analysis: Calculate the curvature distribution of the curves and compare the differences before and after deleting the node.
- Length and Area: Compare geometric features such as the length of the curves and the enclosed area.
- Control Point Analysis: Analyze how changes in the positions and number of control points affect the curve shape.
2. Shape Matching Algorithms
- Hausdorff Distance: Measure the maximum degree of mismatch between two curves.
- Fréchet Distance: Consider the continuity of curves over time to measure their similarity.
- Dynamic Time Warping (DTW): Used to compare the similarity of two curves in the time dimension.
3. Machine Learning Methods
- Deep Learning Models: Use deep learning models like Convolutional Neural Networks (CNNs) to learn features of curve shapes and perform similarity comparisons.
4. Graphic Editing Software
- Many professional graphic editing software (such as Adobe Illustrator, CorelDRAW, etc.) provide automated tools to analyze and compare curve shapes. For example, they can automatically detect nodes on curves and provide shape change analysis before and after deleting nodes.
5. Programming Tools
- Using programming languages (such as Python, MATLAB, etc.) combined with graphics processing libraries (such as OpenCV, Scikit-image, etc.), scripts can be written to perform curve shape comparisons.
Conclusion
While software can measure and compare the similarity between vector curves, manual judgment is still necessary in some cases, especially when considering subjective aesthetics or specific design requirements. However, for most scenarios, software tools can provide objective, quantitative similarity analysis, significantly reducing manual workload.
Please don’t post the “opinion of AI”.
You can make a copy of the path, remove the node there, and then compare the modified copy with the original path. All of that can be done with software.
Is there a specific use case for which you want this functionality? There are many different ways to do path simplification using software. Glyphs includes some of these features. There are also plugins and scripts that might already do what you want to do. Without knowing your needs more specifically, it’s difficult to tell what would be the best way to address path simplification using software.
I plan to write a plug -in to implement these functions with the help of AI.