mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:32:44 +00:00 
			
		
		
		
	FontEditor: Consolidate GlyphEditor's flip_{horizontally,vertically}
This commit is contained in:
		
							parent
							
								
									d867871bda
								
							
						
					
					
						commit
						894b41ef4d
					
				
					 3 changed files with 7 additions and 29 deletions
				
			
		|  | @ -215,40 +215,19 @@ void GlyphEditorWidget::rotate_90(Gfx::RotationDirection direction) | |||
|     update(); | ||||
| } | ||||
| 
 | ||||
| void GlyphEditorWidget::flip_vertically() | ||||
| void GlyphEditorWidget::flip(Gfx::Orientation orientation) | ||||
| { | ||||
|     if (on_undo_event) | ||||
|         on_undo_event(); | ||||
| 
 | ||||
|     auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap(); | ||||
|     auto matrix = glyph_as_matrix(bitmap); | ||||
|     auto vertical = orientation == Gfx::Orientation::Vertical; | ||||
| 
 | ||||
|     for (int y = 0; y < bitmap.height(); y++) { | ||||
|         for (int x = 0; x < bitmap.width(); x++) { | ||||
|             int source_x = x; | ||||
|             int source_y = bitmap.height() - 1 - y; | ||||
|             bool value = matrix[source_y][source_x]; | ||||
|             bitmap.set_bit_at(x, y, value); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (on_glyph_altered) | ||||
|         on_glyph_altered(m_glyph); | ||||
|     update(); | ||||
| } | ||||
| 
 | ||||
| void GlyphEditorWidget::flip_horizontally() | ||||
| { | ||||
|     if (on_undo_event) | ||||
|         on_undo_event(); | ||||
| 
 | ||||
|     auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap(); | ||||
|     auto matrix = glyph_as_matrix(bitmap); | ||||
| 
 | ||||
|     for (int y = 0; y < bitmap.height(); y++) { | ||||
|         for (int x = 0; x < bitmap.width(); x++) { | ||||
|             int source_x = bitmap.width() - 1 - x; | ||||
|             int source_y = y; | ||||
|             int source_x = vertical ? x : bitmap.width() - 1 - x; | ||||
|             int source_y = vertical ? bitmap.height() - 1 - y : y; | ||||
|             bool value = matrix[source_y][source_x]; | ||||
|             bitmap.set_bit_at(x, y, value); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 thankyouverycool
						thankyouverycool