As per the title: using GSPathSegment.reverse() always returns None. I would expect the segment with reversed objects. What is this method supposed to return?
It reverses the segment in place.
Ah, thanks, of course. That makes perfect sense.
You were looking for the .reversed() function.
Yes, but for that, I need to get the points of the segment as a list, reverse the list, and then convert those points to a segment again. segment.reverse() is perfect.
By the way, this is the function I have in order to get the points of a segment:
points = []
for index in range(segment.count()):
points.append(segment.objectAtIndexedSubscript_(index).pointValue())
return points
Is there some easier way of getting a list of points for a GSPathSegment?
Better use segment.pointAtIndex_(index).
points = []
for index in range(len(segment)):
points.append(segment.pointAtIndex_(index))
return points
Ah, thanks. I need to revisit my code and check for simpler methods, since I am still discovering the depths of GSPathSegment and all the methods it offers.
What do you need the points for? Why not use path.nodes?
You told me to ![]()
I’m working with a lot of complex chained transformations, each independent per segment. Using nodes would mess things up. Also, the methods available in the GSPathSegment class are extremely useful, for things like extending and splitting segments.