mirror of
				https://forge.katzen.cafe/katzen-cafe/iowo.git
				synced 2025-10-31 01:27:56 +01:00 
			
		
		
		
	implement invert instruction
This commit is contained in:
		
					parent
					
						
							
								2b3c74053e
							
						
					
				
			
			
				commit
				
					
						e7863402f3
					
				
			
		
					 4 changed files with 50 additions and 13 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| pub mod Read { | ||||
| pub mod read { | ||||
|     use image::{io::Reader as ImageReader, DynamicImage}; | ||||
|     use rpl::instructions::read::{Read, SourceType}; | ||||
| 
 | ||||
|  | @ -12,7 +12,7 @@ pub mod Read { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| pub mod Write { | ||||
| pub mod write { | ||||
|     use image::{io::Reader as ImageReader, DynamicImage, ImageFormat}; | ||||
|     use rpl::instructions::write::{TargetFormat, TargetType, Write}; | ||||
| 
 | ||||
|  | @ -28,3 +28,14 @@ pub mod Write { | |||
|         ); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| pub mod filters { | ||||
|     pub mod invert { | ||||
|         use image::DynamicImage; | ||||
| 
 | ||||
|         pub fn invert(mut input_data: DynamicImage) -> DynamicImage { | ||||
|             input_data.invert(); | ||||
|             input_data | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -1,19 +1,18 @@ | |||
| use rpl::instructions::{FilterInstruction, Instruction}; | ||||
| 
 | ||||
| use crate::{value::DynamicValue, Executor}; | ||||
| mod instructions; | ||||
| 
 | ||||
| pub struct DebugExecutor; | ||||
| 
 | ||||
| impl Executor for DebugExecutor { | ||||
|     fn execute( | ||||
|         instruction: rpl::instructions::Instruction, | ||||
|         input: Option<DynamicValue>, | ||||
|     ) -> Option<DynamicValue> { | ||||
|     fn execute(instruction: Instruction, input: Option<DynamicValue>) -> Option<DynamicValue> { | ||||
|         match instruction { | ||||
|             rpl::instructions::Instruction::Read(read_instruction) => Some(DynamicValue::Image( | ||||
|                 instructions::Read::read(read_instruction), | ||||
|             Instruction::Read(read_instruction) => Some(DynamicValue::Image( | ||||
|                 instructions::read::read(read_instruction), | ||||
|             )), | ||||
|             rpl::instructions::Instruction::Write(write_instruction) => { | ||||
|                 instructions::Write::write( | ||||
|             Instruction::Write(write_instruction) => { | ||||
|                 instructions::write::write( | ||||
|                     write_instruction, | ||||
|                     match input { | ||||
|                         Some(DynamicValue::Image(img)) => img, | ||||
|  | @ -22,9 +21,17 @@ impl Executor for DebugExecutor { | |||
|                 ); | ||||
|                 None | ||||
|             } | ||||
|             rpl::instructions::Instruction::Math(_) => todo!(), | ||||
|             rpl::instructions::Instruction::Blend(_) => todo!(), | ||||
|             rpl::instructions::Instruction::Noise(_) => todo!(), | ||||
|             Instruction::Math(_) => todo!(), | ||||
|             Instruction::Blend(_) => todo!(), | ||||
|             Instruction::Noise(_) => todo!(), | ||||
|             Instruction::Filter(filter_instruction) => match filter_instruction { | ||||
|                 FilterInstruction::Invert => Some(DynamicValue::Image( | ||||
|                     instructions::filters::invert::invert(match input { | ||||
|                         Some(DynamicValue::Image(img)) => img, | ||||
|                         _ => panic!("invalid value type for invert"), | ||||
|                     }), | ||||
|                 )), | ||||
|             }, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Schrottkatze
				Schrottkatze