image icon indicating copy to clipboard operation
image copied to clipboard

EnumeratePixels and EnumerateRows should implement DoubleEndedIterator

Open Pauan opened this issue 1 year ago • 3 comments

The EnumeratePixels and EnumerateRows iterators should implement DoubleEndedIterator.

This will make it possible to iterate in reverse order (for example right-to-left instead of left-to-right).

The Pixels and Rows iterators already implement DoubleEndedIterator.

Pauan avatar Jul 30 '24 02:07 Pauan

Could you provide an example where this would be actually useful? What do you need this functionality for?

Shnatsel avatar Jul 30 '24 14:07 Shnatsel

I'm creating a custom CAM program for CNC machines. The program loads an image, and then iterates over the pixels of the image to generate the GCode.

But it needs to iterate in a specific order to generate optimal GCode. The default order (left-to-right, top-to-bottom) creates suboptimal GCode, which slows down the CNC machine by ~50%.

With DoubleEndedIterator it can iterate in the perfect order.

Pauan avatar Jul 30 '24 16:07 Pauan

I see! Yes, an implementation of DoubleEndedIterator would be nice to have, and shouldn't be difficult. A PR for it would be welcome.

Shnatsel avatar Jul 30 '24 21:07 Shnatsel