kyamagu / skia-python

Python binding to Skia Graphics Library
https://kyamagu.github.io/skia-python/
BSD 3-Clause "New" or "Revised" License
246 stars 43 forks source link

Missing `getBlendMode` on `skia.Paint` objects #235

Closed pavpanchekha closed 8 months ago

pavpanchekha commented 8 months ago

There is a setBlendMode method on Paint objects, but no corresponding getBlendMode. Also, the BlendMode parameter to skia.Paint is not documented

To Reproduce

>>> skia.__version__
'119.0b4'
>>> skia.Paint().getBlendMode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'skia.Paint' object has no attribute 'getBlendMode'. Did you mean: 'setBlendMode'?

To see the documentation issues, search "blendmode" on this page: https://kyamagu.github.io/skia-python/reference/skia.Paint.html Note that the BlendMode argument to the skia.Paint constructor works, but is not documented.

Expected behavior Like in previous releases of skia-python, the getBlendMode function should exist and be documented.

Desktop:

HinTak commented 8 months ago

getBlendMode was removed upstream. There is a new getBlendMode_or(...) function, which seems to overlap somewhat in functionality. Patch welcome.

HinTak commented 8 months ago

This was removed in https://github.com/google/skia/commit/64e67c346c3fe386cda542386831f65d39098bda, which also provides the code for emulating it.

HinTak commented 8 months ago

BlendMode is a class itself - that should be obvious? You read the BlendMode class documentation on what it means.

HinTak commented 8 months ago

I have put the emulation in https://github.com/kyamagu/skia-python/pull/234/commits/69e25c32dc54f120be6228432d06c1b4cf037b2e . Download the new build when it finishes to give it a try if you can.

I am not going to release that as 123bX as 124 is already out, so there will be a pull for m124-public soon, and 124bX will ship with this fix.

pavpanchekha commented 8 months ago

Thank you, perfect. I'll check it out later today. By BlendMode documentation, I mean that BlendMode isn't in the list of possible keyword arguments for skia.Paint.__init__, even though it in fact appears to be a valid keyword argument.

HinTak commented 8 months ago

The docstring indeed seems to never mention Blendmode despite the code clearly can accept it. How do you list the possible keyword arguments?

pavpanchekha commented 8 months ago

Ok, confirming that that build worked. Thank you!