> Thanks for the example.
My pleasure :D Thank you for taking a look!
> Nice example! Presumably if you wanted to do actual Porter-Duff though, you'd want some arithmetic rather than just comparison.
Thank you! And yeah if you wanted to do something like a color-dodge or other blend modes you'd definitely need more operations =)
> One observation: you don't actually need the "comparable" constraint on many of the core entities there (e.g. Rect and Op) because they don't actually use any compare operations. The code works just fine if you omit them:
https://go2goplay.golang.org/p/dKGOaN_v3He
Good point! All Merge requires is that it accepts and returns the given type, no need to force anything to be comparable at that level :D
> Technically, the "z" argument to Op isn't necessary either AFAICS - you could just use a zero value instead (unless you actually want to be able to have a non-zero "zero" value, I guess).
Yeah in this example it's not needed because you just pass 0 hehe, but I wanted to include it because you can make some pretty cool combinations if you change it.
Here's a little example.
But thinking about it... really there's no reason Merge should be passing the zero value around. It's perfectly reasonable to have an Op function that doesn't require one. For example an
averaging function. It probably makes more sense to wrap the functions that do require zero values in a closure, as in
this example. (I know some of those functions don't require z values, but I wanted them to have a uniform type :D)
Thank you for your feedback!
--Beka