more From for Cp437Grid and BitVec
This commit is contained in:
		
							parent
							
								
									eb7496b27d
								
							
						
					
					
						commit
						ab16f57292
					
				
					 5 changed files with 23 additions and 9 deletions
				
			
		|  | @ -14,4 +14,4 @@ version = "0.10.0" | |||
| missing-docs = "warn" | ||||
| 
 | ||||
| [workspace.dependencies] | ||||
| thiserror = "1.0.69" | ||||
| thiserror = "1.0.69" | ||||
|  | @ -42,10 +42,10 @@ fn main() { | |||
|     } | ||||
| 
 | ||||
|     let text = cli.text.join("\n"); | ||||
|     let grid = CharGrid::from(&*text); | ||||
|     let cp437_grid = Cp437Grid::from(&grid); | ||||
|     let grid = CharGrid::from(text); | ||||
|     let grid = Cp437Grid::from(grid); | ||||
| 
 | ||||
|     connection | ||||
|         .send(Command::Cp437Data(Origin::ZERO, cp437_grid)) | ||||
|         .send(Command::Cp437Data(Origin::ZERO, grid)) | ||||
|         .expect("sending text failed"); | ||||
| } | ||||
|  |  | |||
|  | @ -33,12 +33,8 @@ fn main() { | |||
|             enabled_pixels.set(x_offset % PIXEL_WIDTH, y, false); | ||||
|         } | ||||
| 
 | ||||
|         // this works because the pixel grid has max size
 | ||||
|         let pixel_data: Vec<u8> = enabled_pixels.clone().into(); | ||||
|         let bit_vec = BitVec::from_vec(pixel_data); | ||||
| 
 | ||||
|         connection | ||||
|             .send(Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma)) | ||||
|             .send(Command::BitmapLinearWin(Origin::ZERO, enabled_pixels.clone(), CompressionCode::Lzma)) | ||||
|             .expect("could not send command to display"); | ||||
|         thread::sleep(sleep_duration); | ||||
|     } | ||||
|  |  | |||
|  | @ -175,6 +175,12 @@ impl From<Bitmap> for Vec<u8> { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| impl From<Bitmap> for BitVec { | ||||
|     fn from(value: Bitmap) -> Self { | ||||
|         value.bit_vec | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub struct IterRows<'t> { | ||||
|     bitmap: &'t Bitmap, | ||||
|     row: usize, | ||||
|  |  | |||
|  | @ -141,6 +141,12 @@ mod feature_cp437 { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     impl From<CharGrid> for Cp437Grid { | ||||
|         fn from(value: CharGrid) -> Self { | ||||
|             Cp437Grid::from(&value) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     impl From<&str> for CharGrid { | ||||
|         fn from(value: &str) -> Self { | ||||
|             let value = value.replace("\r\n", "\n"); | ||||
|  | @ -166,6 +172,12 @@ mod feature_cp437 { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     impl From<String> for CharGrid { | ||||
|         fn from(value: String) -> Self { | ||||
|             CharGrid::from(&value) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     impl From<&CharGrid> for String { | ||||
|         fn from(value: &CharGrid) -> Self { | ||||
|             value | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter