~ireas/genpdf-rs#38: 
Support rounded corners for frames

Status
REPORTED
Submitter
~ireas
Assigned to
No-one
Submitted
3 years ago
Updated
1 year, 10 months ago
Labels
feature v0.3.0

~ireas referenced this from #34 3 years ago

~ap4sc 3 years ago

I extended my rounded corners implementation to add the ability enable/disable individual sides of the border, set in the new struct BorderStyle. The draw function isn't pretty but after several attempts this "manual" mapping method is the most efficient I could think of. On the plus side it simplifies the element code by automatically figuring out which corners need to be connected and rounded.

https://git.sr.ht/~ap4sc/genpdf-rs/commit/fbf8656c3d2e25a8aab2f901f4f5bc92ff9b924a

One way to make it more modular in the future could be to move the rounded corners, LineStyle, [and fill color] into a separate RoundedRectangle shape struct for reuse in the shapes drawing feature

~ireas 3 years ago

My idea for the API is:

  • Create a new RoundedCorners struct similar to Margins that can be constructed from a single value for all four corners, or from four different corners.
  • Change FramedElement so that new is the only constructor and that there are these setters:
    • set_line_style / with_line_style
    • set_rounded_corners / with_rounded_corners
    • set_fill_color / with_fill_color (eventually)

I see that you made it possible to select which borders to draw. This could be fitted in this model by creating a Borders struct with four boolean values (again similar to Margins) and set_borders / with_borders setters in FramedElement.

If it makes sense for the implementation (for example to reduce the number of arguments in the draw methods), you can combine these settings in a BorderStyle or FrameStyle struct. But this should be an implementation detail of the FramedElement and not directly exposed to the user.

Does that make sense to you? If yes, please submit the patches.

~bharath412 1 year, 10 months ago

is set_fill_color / with_fill_color for FrameCellDecorator implemented? If yes, can you please share a sample

Register here or Log in to comment, or comment via email.