As a result of the two difference functions not accounting for transparency, when the hill climb occurs, it will often place spurious primitives that are designed to match the background. While for many use cases this isn't really an issue, when dealing with transparent or semi-transparent pngs, it can be a bit problematic. Here is an example of the modified version in action, executed with -bg 00000000:
The left-most image was the original source. Notice the transparent background and semi-transparent lens region. In the middle image, the current version of primitive, a number of unwanted black ellipses are placed. Once you tell the algorithm to pay attention to transparency, the results improve drastically as shown in the right-most image (n.b. some of the black ellipses are from the shadow, however it is easy to see that many of them have no corresponding visible counterpart).
Concerns
While this should not affect the output on fully opaque images, it may result in a slight speed decrease, as there is now one additional array access per pixel in the difference algorithm. While I was not able to notice any change, this is worth considering.
[Resolves fogleman/primitive#31]
Overview
As a result of the two difference functions not accounting for transparency, when the hill climb occurs, it will often place spurious primitives that are designed to match the background. While for many use cases this isn't really an issue, when dealing with transparent or semi-transparent pngs, it can be a bit problematic. Here is an example of the modified version in action, executed with
-bg 00000000
:The left-most image was the original source. Notice the transparent background and semi-transparent lens region. In the middle image, the current version of primitive, a number of unwanted black ellipses are placed. Once you tell the algorithm to pay attention to transparency, the results improve drastically as shown in the right-most image (n.b. some of the black ellipses are from the shadow, however it is easy to see that many of them have no corresponding visible counterpart).
Concerns
While this should not affect the output on fully opaque images, it may result in a slight speed decrease, as there is now one additional array access per pixel in the difference algorithm. While I was not able to notice any change, this is worth considering.