Carousel: the other four pills in the row's order, two left and two right of the card, so the left-most stay left-most; none changes sides on opening
This commit is contained in:
+14
-10
@@ -303,15 +303,15 @@ fn index(item: Item) -> usize {
|
||||
}
|
||||
|
||||
/*
|
||||
* the two items on each side of `open`'s card, always: the row's order going round, so
|
||||
* the ones past an end of the row come in on the other side (around Home: System and the
|
||||
* island on its left, the bell and AI on its right)
|
||||
* the two items on each side of `open`'s card: the other four in the row's order, the
|
||||
* first two on its left and the last two on its right, so the left-most stays left-most
|
||||
* (around Home: AI and System on its left, the island and the bell on its right; around
|
||||
* AI: System and the island on its left, Home and the bell on its right)
|
||||
*/
|
||||
fn beside(open: Pod) -> ([Item; 2], [Item; 2]) {
|
||||
let (count, at) = (ROW.len(), index(Item::Pod(open)));
|
||||
let step = |by: usize| ROW[(at + by) % count];
|
||||
let others: Vec<Item> = ROW.into_iter().filter(|item| *item != Item::Pod(open)).collect();
|
||||
|
||||
([step(count - 2), step(count - 1)], [step(1), step(2)])
|
||||
([others[0], others[1]], [others[2], others[3]])
|
||||
}
|
||||
|
||||
// an item's left edge in the carousel around `open`'s card, `card_w` wide, in the middle, and its side of the card (-1, 0 for the card's own, 1)
|
||||
@@ -340,9 +340,13 @@ fn carousel(item: Item, open: Pod, card_w: f32, middle: f32) -> (f32, i8) {
|
||||
}
|
||||
}
|
||||
|
||||
// an item's side of `open` in the closed row
|
||||
fn closed_side(item: Item, open: Pod) -> i8 {
|
||||
(index(item) as i8 - index(Item::Pod(open)) as i8).signum()
|
||||
/*
|
||||
* an item's side of the middle in the closed row, where every card opens: AI and System
|
||||
* left, the island in it (0, so it slides out to whichever side it goes), Home and the
|
||||
* bell right. no item changes sides on opening, so none crosses the card
|
||||
*/
|
||||
fn closed_side(item: Item) -> i8 {
|
||||
(index(item) as i8 - index(Item::Island) as i8).signum()
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -408,7 +412,7 @@ impl Scene {
|
||||
None => (now.0, 1.0, now.1),
|
||||
};
|
||||
|
||||
let (x, shown) = travel((closed, closed_side(item, open)), (open_x, open_side), self.row_grow);
|
||||
let (x, shown) = travel((closed, closed_side(item)), (open_x, open_side), self.row_grow);
|
||||
|
||||
(x, shown * open_shown)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user