Skip to content

Commit

Permalink
allow setting x and y radii separately
Browse files Browse the repository at this point in the history
hit testing only takes x radius into account
  • Loading branch information
tomara-x committed May 27, 2024
1 parent 87a66f4 commit 96b1399
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ pub fn command_parser(
}
}
Some(":set") | Some("set") | Some(":delta") | Some("delta") => {
match command.next() {
let c1 = command.next();
match c1 {
Some("n") => {
if let Some(s) = command.next() {
if let Some(e) = str_to_id(s) {
Expand Down Expand Up @@ -319,18 +320,30 @@ pub fn command_parser(
}
}
}
Some("r") => {
Some("r") | Some("rx") | Some("ry") => {
if let Some(s) = command.next() {
if let Some(e) = str_to_id(s) {
if let Ok(mut trans) = access.trans_query.get_mut(e) {
if let Some(n) = command.next() {
if let Ok(n) = parse_with_constants(n) {
if c0 == Some(":set") || c0 == Some("set") {
trans.scale.x = n.max(0.);
trans.scale.y = n.max(0.);
if c1 == Some("r") {
trans.scale.x = n.max(0.);
trans.scale.y = n.max(0.);
} else if c1 == Some("rx") {
trans.scale.x = n.max(0.);
} else {
trans.scale.y = n.max(0.);
}
} else {
trans.scale.x = (trans.scale.x+n).max(0.);
trans.scale.y = (trans.scale.y+n).max(0.);
if c1 == Some("r") {
trans.scale.x = (trans.scale.x+n).max(0.);
trans.scale.y = (trans.scale.y+n).max(0.);
} else if c1 == Some("rx") {
trans.scale.x = (trans.scale.x+n).max(0.);
} else {
trans.scale.y = (trans.scale.y+n).max(0.);
}
}
lt_to_open = (Some(e), Some(-2));
}
Expand All @@ -340,11 +353,23 @@ pub fn command_parser(
for id in access.selected_query.iter() {
if let Ok(mut trans) = access.trans_query.get_mut(id) {
if c0 == Some(":set") || c0 == Some("set") {
trans.scale.x = n.max(0.);
trans.scale.y = n.max(0.);
if c1 == Some("r") {
trans.scale.x = n.max(0.);
trans.scale.y = n.max(0.);
} else if c1 == Some("rx") {
trans.scale.x = n.max(0.);
} else {
trans.scale.y = n.max(0.);
}
} else {
trans.scale.x = (trans.scale.x+n).max(0.);
trans.scale.y = (trans.scale.y+n).max(0.);
if c1 == Some("r") {
trans.scale.x = (trans.scale.x+n).max(0.);
trans.scale.y = (trans.scale.y+n).max(0.);
} else if c1 == Some("rx") {
trans.scale.x = (trans.scale.x+n).max(0.);
} else {
trans.scale.y = (trans.scale.y+n).max(0.);
}
}
}
}
Expand Down

0 comments on commit 96b1399

Please sign in to comment.