feat: graph-ir (continueing #6) #10

Merged
schrottkatze merged 37 commits from schrottkatze/iowo:graph-ir into main 2024-01-23 12:55:01 +00:00
5 changed files with 15 additions and 15 deletions
Showing only changes of commit ccbccfb11b - Show all commits

View file

@ -1,4 +1,4 @@
use rpl::instructions::{FilterInstruction, Instruction};
use rpl::instructions::{Filter, Instruction};
use crate::value::Dynamic;
mod instructions;
@ -25,12 +25,12 @@ impl crate::Executor for Executor {
Instruction::Blend(_) => todo!(),
Instruction::Noise(_) => todo!(),
Instruction::Filter(filter_instruction) => match filter_instruction {
FilterInstruction::Invert => Some(Dynamic::Image(
instructions::filters::invert::invert(match input {
Filter::Invert => Some(Dynamic::Image(instructions::filters::invert::invert(
match input {
Some(Dynamic::Image(img)) => img,
_ => panic!("invalid value type for invert"),
}),
)),
},
))),
},
}
}

View file

@ -7,14 +7,14 @@ pub mod write;
pub enum Instruction {
Read(read::Read),
Write(write::Write),
Math(MathInstruction),
Blend(BlendInstruction),
Noise(NoiseInstruction),
Filter(FilterInstruction),
Math(Math),
Blend(Blend),
Noise(Noise),
Filter(Filter),
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub enum MathInstruction {
pub enum Math {
Add,
Subtract,
Multiply,
@ -22,7 +22,7 @@ pub enum MathInstruction {
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub enum BlendInstruction {
pub enum Blend {
Normal,
Multiply,
Additive,
@ -35,13 +35,13 @@ pub enum BlendInstruction {
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub enum NoiseInstruction {
pub enum Noise {
Perlin,
Simplex,
Voronoi,
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
pub enum FilterInstruction {
pub enum Filter {
Invert,
}

View file

@ -20,7 +20,7 @@ mod tests {
use crate::instructions::{
read::{SourceFormat, SourceType},
write::{TargetFormat, TargetType},
MathInstruction,
Math,
};
#[test]
@ -40,7 +40,7 @@ mod tests {
source: SourceType::File("~/example/file.png".into()),
format: SourceFormat::Png
}),
Instruction::Math(MathInstruction::Add),
Instruction::Math(Math::Add),
Instruction::Write(instructions::write::Write {
target: TargetType::File("~/example/out.jpg".into()),
format: TargetFormat::Jpeg