Linear and Radial gradients support #308
Replies: 5 comments 7 replies
-
This interface is confusing to me:
I would much prefer to have one method, container could still have a clean implementation - separate private functions for different types of background_layer, and then draw_background_layer would just call them. I don't see the need to lift this distinction to API level. I like how background_layer concept encapsulates different types of images, and I think this is a nice object to pass through API boundary. On the other hand, using |
Beta Was this translation helpful? Give feedback.
-
After some more thinking I realized that I actually like your idea to have more basic drawing functions in the interface. My problem is the mentioning of the background in those functions. This is what I would like to have: void draw_image (uint_ptr hdc, const string& url, pixel_rect rect);
void draw_solid_rect (uint_ptr hdc, web_color color, pixel_rect rect);
void draw_linear_gradient(uint_ptr hdc, const linear_gradient& gradient, pixel_rect rect);
void draw_radial_gradient(uint_ptr hdc, const radial_gradient& gradient, pixel_rect rect); That is, those functions don't have to be concerned about gradients, they should not know what they are used for. They just do their little thing - fill rectangle with something. If we add draw_circle/draw_solid_circle, we can get rid of |
Beta Was this translation helpful? Give feedback.
-
@stasoid thank you for testing. As for images there are two ways HTML/CSS processes the images:
For BTW, gradients are images too in terms of CSS. So there are two type of backgrounds from CSS view point: solid color and images.
@kobalicek, Generally this is how
Looking at structures I've created in the gradient branch I see:
So maybe this implementation of background interface is not so bad:
Just unite all style specific (image, color, gradients) into the PS. It is difficult decision, thank you for helping in selecting the best implementation. |
Beta Was this translation helpful? Give feedback.
-
I am writing a standard-compliant CSS parser now. I am mentioning it here because I will rewrite everything in terms of CSS tokens, including gradients. It sucks that a good part of your work on gradients will be almost immediately replaced. |
Beta Was this translation helpful? Give feedback.
-
I'm happy with this branch. I've converted my view class over to use the new API and also added round corner support to get this working: |
Beta Was this translation helpful? Give feedback.
-
I'm near to finish implementing linear and radial gradients. You can find current implementation in this branch https://github.com/litehtml/litehtml/tree/gradient. Example of of gradients rendering:
Important
The interface of
document_container
was changed. I've removeddraw_background
super-method and added 4 new methods for each fill/draw type:What do you think about this? Comments are appreciated!
Beta Was this translation helpful? Give feedback.
All reactions