mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:42:43 +00:00 
			
		
		
		
	LibGfx: Implement checkerboard drawing for Gfx::Painter
This commit is contained in:
		
							parent
							
								
									de32fd0347
								
							
						
					
					
						commit
						e14d27867c
					
				
					 2 changed files with 20 additions and 0 deletions
				
			
		|  | @ -142,6 +142,25 @@ void Painter::fill_rect(const Rect& a_rect, Color color) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void Painter::fill_rect_with_checkerboard(const Rect& a_rect, const Size& cell_size, Color color_dark, Color color_light) | ||||
| { | ||||
|     auto rect = a_rect.translated(translation()).intersected(clip_rect()); | ||||
|     if (rect.is_empty()) | ||||
|         return; | ||||
| 
 | ||||
|     RGBA32* dst = m_target->scanline(rect.top()) + rect.left(); | ||||
|     const size_t dst_skip = m_target->pitch() / sizeof(RGBA32); | ||||
| 
 | ||||
|     for (int i = 0; i < rect.height(); ++i) { | ||||
|         for (int j = 0; j < rect.width(); ++j) { | ||||
|             int cell_row = i / cell_size.height(); | ||||
|             int cell_col = j / cell_size.width(); | ||||
|             dst[j] = ((cell_row % 2) ^ (cell_col % 2)) ? color_light.value() : color_dark.value(); | ||||
|         } | ||||
|         dst += dst_skip; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Painter::fill_rect_with_gradient(Orientation orientation, const Rect& a_rect, Color gradient_start, Color gradient_end) | ||||
| { | ||||
| #ifdef NO_FPU | ||||
|  |  | |||
|  | @ -45,6 +45,7 @@ public: | |||
|     ~Painter(); | ||||
|     void clear_rect(const Rect&, Color); | ||||
|     void fill_rect(const Rect&, Color); | ||||
|     void fill_rect_with_checkerboard(const Rect&, const Size&, Color color_dark, Color color_light); | ||||
|     void fill_rect_with_gradient(Orientation, const Rect&, Color gradient_start, Color gradient_end); | ||||
|     void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end); | ||||
|     void draw_rect(const Rect&, Color, bool rough = false); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Tibor Nagy
						Tibor Nagy