Skip to content

Commit

Permalink
modifyExtrusionDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
MattFerraro committed Apr 10, 2024
1 parent bef6880 commit 991bf5e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
7 changes: 6 additions & 1 deletion packages/cadmium/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fn main() {
});
let extrude_sha = el.append(Operation::NewExtrusion {
name: "Extrude1".to_string(),
unique_id: "abc123".to_string(),
sketch_name: "Sketch1".to_string(),
click_x: 50.0,
click_y: 50.0,
Expand All @@ -53,8 +54,12 @@ fn main() {
});
el.cherry_pick(extrude_sha);

el.pretty_print();
el.append(Operation::ModifyExtrusionDepth {
unique_id: "abc123".to_string(),
depth: 200.0,
});

el.pretty_print();
}

fn main_old() {
Expand Down
58 changes: 36 additions & 22 deletions packages/cadmium/src/oplog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,23 @@ pub enum Operation {
width: f64,
height: f64,
},
NewCircle {
sketch_name: String,
x: f64,
y: f64,
radius: f64,
},
NewExtrusion {
name: String,
unique_id: String,
sketch_name: String,
click_x: f64,
click_y: f64,
depth: f64,
},
NewCircle {
sketch_name: String,
x: f64,
y: f64,
radius: f64,
ModifyExtrusionDepth {
unique_id: String,
depth: f64,
},
}

Expand Down Expand Up @@ -195,20 +200,25 @@ impl Operation {
width,
height,
} => hasher.update(format!("{sketch_name}-{x}-{y}-{width}-{height}").as_bytes()),
Operation::NewExtrusion {
name,
sketch_name,
click_x,
click_y,
depth,
} => hasher
.update(format!("{name}-{sketch_name}-{click_x}-{click_y}-{depth}").as_bytes()),
Operation::NewCircle {
sketch_name,
x,
y,
radius,
} => hasher.update(format!("{sketch_name}-{x}-{y}-{radius}").as_bytes()),
Operation::NewExtrusion {
name,
unique_id,
sketch_name,
click_x,
click_y,
depth,
} => hasher.update(
format!("{name}-{unique_id}-{sketch_name}-{click_x}-{click_y}-{depth}").as_bytes(),
),
Operation::ModifyExtrusionDepth { unique_id, depth } => {
hasher.update(format!("{unique_id}-{depth}").as_bytes())
}
}

format!("{:x}", hasher.finalize())
Expand All @@ -235,8 +245,18 @@ impl Operation {
"NewRectangle: {} {} {} {} on '{}'",
x, y, width, height, sketch_name
),
Operation::NewCircle {
sketch_name,
x,
y,
radius,
} => format!(
"NewCircle: ({},{}) radius: {} on '{}'",
x, y, radius, sketch_name
),
Operation::NewExtrusion {
name,
unique_id,
sketch_name,
click_x,
click_y,
Expand All @@ -245,15 +265,9 @@ impl Operation {
"NewExtrusion: '{}' on '{}' ({},{}) depth: {}",
name, sketch_name, click_x, click_y, depth
),
Operation::NewCircle {
sketch_name,
x,
y,
radius,
} => format!(
"NewCircle: ({},{}) radius: {} on '{}'",
x, y, radius, sketch_name
),
Operation::ModifyExtrusionDepth { unique_id, depth } => {
format!("ModifyExtrusionDepth: {} to {}", unique_id, depth)
}
}
}
}

0 comments on commit 991bf5e

Please sign in to comment.