Closed Neon22 closed 1 month ago
I like what you did with rtf.add_color
! However, it's a bit different from how Line
color works currently. It could be confusing for other users that the two color arguments work differently.
Before I merge, could you update how colors work with lines to use the same interface? That way, it will be easier for new users to understand how colors work.
I think the cleanest design is for both to take a Color
object that is registered and returned by rtf.add_color
. Concretely, I suggest the following design:
Color
to be a class with four fields:class Color(NamedTuple):
red: int
green: int
blue: int
cid: int
rtf.add_color(r, g, b)
returns a Color
object as follows:
def add_color(self, r, g, b) -> Color:
cid = self.color_counter
self.color_counter += 1
return Color(r, g, b, cid)
Line(color=...)
and Table(bg_color=...)
can take an object of type Color
. The implementation can access the color ID with color.cid
. This simplifies a lot of the messy code before with the secret self.__cid__
field.Let me know if anything is unclear or you have questions/other ideas.
Thanks, will get to it soon.
new PR raised
closing as superseded
modified rtf.py to allow for add_color which returns index of the rgb for use on a row background
modified table to allow addition of bgtable color pattern.
also cleaned up my additions a little