let (op, d) = v["op"].as_object().unwrap().iter().next().unwrap();
fn coord(j: &JsV) -> Pos {
- PosC(
+ PosC::from_iter_2(
j.as_array().unwrap().iter()
.map(|n| n.as_i64().unwrap().try_into().unwrap())
- .collect::<ArrayVec<_>>().into_inner().unwrap()
)
}
fn api(&self) -> Option<PieceOpData> { Some((self.0, self.1.clone())) }
}
impl PieceOp for Pos {
- fn api(&self) -> Option<PieceOpData> { Some(("m", json![self.0])) }
+ fn api(&self) -> Option<PieceOpData> { Some(("m", json![self.coords])) }
fn update(&self, pi: &mut PieceInfo<JsV>) { pi.pos = *self }
}
impl PieceOp for () {
let llm: [_;2] = llm.into_inner().unwrap();
dbgc!(&llm);
- for (llm, &pos) in izip!(&llm, [PosC([5,5]), PosC([50,25])].iter())
+ for (llm, &pos) in izip!(&llm, [PosC::new(5,5), PosC::new(50,25)].iter())
{
session.api_piece(GH::With, &llm.id, pos)?;
}
.collect::<ArrayVec<[_;2]>>()
.into_inner().unwrap();
- pawns.sort_by_key(|&p| -pieces[p].pos.0[0]);
+ pawns.sort_by_key(|&p| -pieces[p].pos.x());
dbgc!(pawns)
}
// ----- alice: move pawns into alice's hand -----
for (&pawn, &xoffset) in izip!(&a_pawns, [10,20].iter()) {
- let pos = (a_pieces[hand].pos + PosC([xoffset, 0]))?;
+ let pos = (a_pieces[hand].pos + PosC::new(xoffset, 0))?;
alice.api_piece(GH::With, (&mut a_pieces, pawn), pos)?;
}
{
let p = a_pawns[0];
- let alice_move_to = (a_pieces[p].pos + PosC([5, 5]))?;
+ let alice_move_to = (a_pieces[p].pos + PosC::new(5,5))?;
let mut a_p = (&mut a_pieces, p);
alice.api_piece(GH::Grab, PuSynch(&mut a_p), ())?;
alice.api_piece(GH::With,
(&mut a_pieces, a_pawns[0]),
- PosC([ 15, 20 ]))?;
+ PosC::new( 15, 20 ))?;
alice.synchu(&mut a_pieces)?;
bob.synchu(&mut b_pieces)?;
pub type Coord = i32;
-#[derive(Clone,Copy,Debug,Serialize,Deserialize,Hash)]
+#[derive(Clone,Copy,Serialize,Deserialize,Hash)]
#[derive(Eq,PartialEq,Ord,PartialOrd)]
#[serde(transparent)]
-pub struct PosC<T>(pub [T; 2]);
+pub struct PosC<T>{ pub coords: [T; 2] }
pub type Pos = PosC<Coord>;
-#[derive(Clone,Copy,Debug,Serialize,Deserialize,Hash)]
-#[derive(Eq,PartialEq)]
+#[derive(Clone,Copy,Serialize,Deserialize,Hash)]
+#[derive(Eq,PartialEq,Ord,PartialOrd)]
#[serde(transparent)]
-pub struct RectC<T>(pub [PosC<T>; 2]);
+pub struct RectC<T>{ pub corners: [PosC<T>; 2] }
pub type Rect = RectC<Coord>;
// ---------- CheckedArith ----------
pub struct PosCFromIteratorError;
display_as_debug!{PosCFromIteratorError}
+impl<T> PosC<T> {
+ pub const fn new(x: T, y: T) -> Self { PosC{ coords: [x,y] } }
+ pub fn both(v: T) -> Self where T: Copy { PosC::new(v,v) }
+ pub fn zero() -> Self where T: num_traits::Zero + Copy {
+ PosC::both(<T as num_traits::Zero>::zero())
+ }
+}
+impl<T> PosC<T> where T: Copy {
+ pub fn x(self) -> T { self.coords[0] }
+ pub fn y(self) -> T { self.coords[1] }
+}
+
impl<T> PosC<T> {
#[throws(PosCFromIteratorError)]
- pub fn from_iter<I: Iterator<Item=T>>(i: I) -> Self { PosC(
+ pub fn from_iter<I: Iterator<Item=T>>(i: I) -> Self { PosC{ coords:
i
.collect::<ArrayVec<_>>()
.into_inner()
.map_err(|_| PosCFromIteratorError)?
- )}
+ }}
+}
+
+impl<T> PosC<T> where T: Debug {
+ pub fn from_iter_2<I: Iterator<Item=T>>(i: I) -> Self { PosC{ coords:
+ i
+ .collect::<ArrayVec<_>>()
+ .into_inner()
+ .unwrap()
+ }}
+}
+
+impl<T> Debug for PosC<T> where T: Debug + Copy {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut Formatter) {
+ write!(f, "[{:?},{:?}]", self.x(), self.y())?;
+ }
}
impl<T:Debug> PosC<T> {
pub fn try_from_iter_2<
E: Debug,
I: Iterator<Item=Result<T,E>>
- >(i: I) -> Self { PosC(
+ >(i: I) -> Self { PosC{ coords:
i
.collect::<Result<ArrayVec<_>,E>>()?
.into_inner().unwrap()
- )}
+ }}
}
impl<T:CheckedArith> Add<PosC<T>> for PosC<T> {
fn add(self, rhs: PosC<T>) -> PosC<T> {
PosC::try_from_iter_2(
itertools::zip_eq(
- self.0.iter().cloned(),
- rhs .0.iter().cloned(),
+ self.coords.iter().cloned(),
+ rhs .coords.iter().cloned(),
).map(
|(a,b)| a.checked_add(b)
)
fn sub(self, rhs: PosC<T>) -> PosC<T> {
PosC::try_from_iter_2(
itertools::zip_eq(
- self.0.iter().cloned(),
- rhs .0.iter().cloned(),
+ self.coords.iter().cloned(),
+ rhs .coords.iter().cloned(),
).map(|(a,b)| a.checked_sub(b))
)?
}
#[throws(CoordinateOverflow)]
fn mul(self, rhs: S) -> PosC<T> {
PosC::try_from_iter_2(
- self.0.iter().cloned().map(
+ self.coords.iter().cloned().map(
|a| a.checked_mul(rhs)
)
)?
#[throws(CoordinateOverflow)]
fn neg(self) -> Self {
PosC::try_from_iter_2(
- self.0.iter().cloned().map(|a| a.checked_neg())
+ self.coords.iter().cloned().map(|a| a.checked_neg())
)?
}
}
impl<T:Copy+Clone+Debug> PosC<T> {
pub fn map<U:Copy+Clone+Debug, F: FnMut(T) -> U>(self, f: F) -> PosC<U> {
PosC::from_iter(
- self.0.iter().cloned().map(f)
+ self.coords.iter().cloned().map(f)
).unwrap()
}
}
(self, f: F) -> Result<PosC<U>,E>
{
PosC::try_from_iter_2(
- self.0.iter().cloned().map(f)
+ self.coords.iter().cloned().map(f)
)
}
}
impl<T> Mean for PosC<T> where T: Mean + Debug {
fn mean(&self, other: &Self) -> Self where T: Mean {
- PosC::try_from_iter_2(
- izip!(&self.0, &other.0)
- .map(|(a,b)| Ok::<_,Void>(a.mean(b)))
- ).unwrap_or_else(|v| match v { })
+ PosC::from_iter_2(
+ izip!(&self.coords, &other.coords)
+ .map(|(a,b)| a.mean(b))
+ )
}
}
// ---------- Rect ----------
+impl<T> RectC<T> where T: Copy {
+ pub fn tl(&self) -> PosC<T> { self.corners[0] }
+ pub fn br(&self) -> PosC<T> { self.corners[1] }
+}
+
+impl<T> Debug for RectC<T> where T: Debug + Copy {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut Formatter) {
+ write!(f, "Rect[{:?},{:?}]", self.tl(), self.br())?;
+ }
+}
+
impl<T> RectC<T> {
- pub fn contains(&self, p: PosC<T>) -> bool where T: PartialOrd {
+ pub fn contains(&self, p: PosC<T>) -> bool where T: PartialOrd + Copy {
(0..2).all(|i| {
- p.0[i] >= self.0[0].0[i] &&
- p.0[i] <= self.0[1].0[i]
+ p.coords[i] >= self.tl().coords[i] &&
+ p.coords[i] <= self.br().coords[i]
})
}
- pub fn overlaps(&self, other: &RectC<T>) -> bool where T: PartialOrd {
+ pub fn overlaps(&self, other: &RectC<T>) -> bool where T: PartialOrd + Copy {
! (0..2).any(|i| (
- other.0[1].0[i] < self .0[0].0[i] ||
- self .0[1].0[i] < other.0[0].0[i]
+ other.br().coords[i] < self .tl().coords[i] ||
+ self .br().coords[i] < other.tl().coords[i]
))
}
- pub fn empty() -> Self where T: Copy + num_traits::Zero + num_traits::One {
- let zero = <T as num_traits::Zero>::zero();
- let one = <T as num_traits::One>::one();
- RectC([
- PosC([ one, one ]),
- PosC([ zero, zero ]),
- ])
+ pub fn empty() -> Self where T: num_traits::Zero + num_traits::One + Copy {
+ RectC{ corners: [
+ PosC::both( <T as num_traits::One >::one() ),
+ PosC::both( <T as num_traits::Zero>::zero() ),
+ ]}
}
}
-impl<T> RectC<T> where T: Mean + Debug {
+impl<T> RectC<T> where T: Mean + Debug + Copy {
pub fn middle(&self) -> PosC<T> {
- Mean::mean(&self.0[0],
- &self.0[1])
+ Mean::mean(&self.tl(),
+ &self.br())
}
}
fn empty_area() {
let empty = Rect::empty();
for x in -3..3 { for y in -3..3 {
- assert!(! empty.contains(PosC([x,y])));
+ dbg!(empty,x,y);
+ assert!(! empty.contains(PosC::new(x,y)));
} }
}
// ---------- Region ----------
#[derive(Clone,Debug,Serialize,Deserialize)]
-pub enum RegionC<T> {
+pub enum RegionC<T:Copy> {
Rectangle(RectC<T>),
}
pub type Region = RegionC<Coord>;
-impl<T> RegionC<T> {
+impl<T:Copy> RegionC<T> {
pub fn contains(&self, pos: PosC<T>) -> bool where T: PartialOrd {
use RegionC::*;
match &self {
const CREATE_PIECES_MAX: u32 = 300;
const OVERALL_PIECES_MAX: usize = 100_000; // don't make not fit in i32
-const DEFAULT_POS_START: Pos = PosC([20,20]);
-const DEFAULT_POS_DELTA: Pos = PosC([5,5]);
+const DEFAULT_POS_START: Pos = PosC::new(20,20);
+const DEFAULT_POS_DELTA: Pos = PosC::new(5,5);
pub struct CommandListener {
listener: UnixListener,
(U{ pcs: vec![],
log: vec![ LogEntry {
html: Html(format!("{} resized the table to {}x{}",
- &who.0, size.0[0], size.0[1])),
+ &who.0, size.x(), size.y())),
}],
raw: Some(vec![ PreparedUpdateEntry::SetTableSize(size) ]) },
Fine, None, ig)
}
Good([a, b]) => {
// todo: take account of the space used by the markers themselves
- let lhs = min(a.0[0], b.0[0]);
- let rhs = max(a.0[0], b.0[0]);
- let top = min(a.0[1], b.0[1]);
- let bot = max(a.0[1], b.0[1]);
+ let lhs = min(a.x(), b.x());
+ let rhs = max(a.x(), b.x());
+ let top = min(a.y(), b.y());
+ let bot = max(a.y(), b.y());
Placement {
lhs, rhs, top, bot,
clhs: lhs, cbot: top,
impl Placement {
/// If returns None, has already maybe tried to take some space
#[throws(AE)]
- fn place(&mut self, bbox: &[Pos;2],
+ fn place(&mut self, bbox: &Rect,
pieces: &Vec<MgmtGamePieceInfo>, ma: &MainOpts)
-> Option<Pos> {
- let PosC([w,h]) = (bbox[1] - bbox[0])?;
+ let PosC{ coords: [w,h] } = (bbox.br() - bbox.tl())?;
let mut did_newline = false;
let (ncbot, tlhs) = 'search: loop {
if let Some((nclhs, clash_bot)) = pieces.iter()
.filter_map(|p| (|| if_chain! {
if let Some(pv) = p.visible.as_ref();
- let tl = (pv.pos + pv.bbox[0])?;
- let br = (pv.pos + pv.bbox[1])?;
- if !(tl.0[0] >= self.clhs
- || tl.0[1] >= ncbot
- || br.0[0] <= tlhs
- || br.0[1] <= self.top);
+ let tl = (pv.pos + pv.bbox.tl())?;
+ let br = (pv.pos + pv.bbox.br())?;
+ if !(tl.x() >= self.clhs
+ || tl.y() >= ncbot
+ || br.x() <= tlhs
+ || br.y() <= self.top);
then {
if ma.verbose > 2 {
eprintln!(
&self, tlhs, ncbot, &p.itemname, &tl, &br
)
}
- Ok::<_,AE>(Some((br.0[0], br.0[1])))
+ Ok::<_,AE>(Some((br.x(), br.y())))
} else {
Ok::<_,AE>(None)
}
// if we are simply too wide, we'll just loop until off the bottom
};
self.cbot = ncbot;
- let ttopleft = PosC([tlhs, self.top]);
- let tnominal = (ttopleft - bbox[0])?;
+ let ttopleft = PosC::new(tlhs, self.top);
+ let tnominal = (ttopleft - bbox.tl())?;
if ma.verbose > 3 { dbgc!(&self, &tnominal); }
Some(tnominal)
let bbox = p
.bbox_approx()?;
- let mut bbox = bbox
- .iter()
- .map(|PosC(xy)| xy.iter().map(|&p| p as f64).collect::<Vec<_>>())
+ let mut bbox = bbox.corners.iter()
+ .map(|PosC{coords}| coords.iter().map(|&p| p as f64)
+ .collect::<Vec<_>>())
.collect::<Vec<_>>();
for xy in &mut bbox[0] { *xy -= BORDER }
for xy in &mut bbox[1] { *xy += BORDER }
const W: Coord = 40;
const H: Coord = 14;
-const OUTLINE: Rectangle = Rectangle { xy: PosC([W as f64, H as f64]) };
+const OUTLINE: Rectangle = Rectangle { xy: PosC::new(W as f64, H as f64) };
// ==================== piece management, loading, etc. ====================
to OUTLINE {
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
- fn bbox_approx(&self) -> Result<[Pos;2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}
}
}
pub pos: Pos,
pub face: FaceId,
pub desc_html: Html,
- pub bbox: [Pos;2],
+ pub bbox: Rect,
}
#[derive(Debug,Copy,Clone,Serialize,Deserialize)]
to self.shape {
fn outline_path(&self, scale: f64) -> Result<Html,IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>,IE>;
- fn bbox_approx(&self) -> Result<[Pos;2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}
}
}
#[serde(transparent)]
pub struct Timestamp(pub u64); /* time_t */
-pub const DEFAULT_TABLE_SIZE: Pos = PosC([ 400, 200 ]);
+pub const DEFAULT_TABLE_SIZE: Pos = PosC::new( 400, 200 );
// ---------- general data types ----------
self.outline_path(SELECT_SCALE)
}
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
- fn bbox_approx(&self) -> Result<[Pos;2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}
#[derive(Debug,Copy,Clone,Serialize,Deserialize)]
fn clamped(self, range: Pos) -> Result<Pos, Pos> {
let mut output = ArrayVec::new();
let mut ok = true;
- for (&pos, &rng) in izip!(self.0.iter(), range.0.iter()) {
+ for (&pos, &rng) in izip!(self.coords.iter(), range.coords.iter()) {
output.push(match pos.clamped(rng) {
Ok(pos) => pos,
Err(pos) => { ok = false; pos },
})
}
- let output = PosC(output.into_inner().unwrap());
+ let output = PosC{ coords: output.into_inner().unwrap() };
if ok { Ok(output) } else { Err(output) }
}
}
pub fn dummy() -> Self {
let gen_dummy = Generation(1);
GPiece {
- pos: PosC([0,0]),
+ pos: PosC::zero(),
face: default(),
held: None,
zlevel: ZLevel { z: default(), zg: gen_dummy },
impl GameState {
pub fn dummy() -> Self { GameState {
table_colour: Html::lit("green"),
- table_size: PosC([300,200]),
+ table_size: PosC::new(300,200),
pieces: default(),
gen: Generation(0),
log: default(),
to self.shape {
fn outline_path(&self, scale: f64) -> Result<Html,IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>,IE>;
- fn bbox_approx(&self) -> Result<[Pos;2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}
}
}
OD::Stack{pos} => *pos,
OD::Rect{rect} => (|| Some({
let notch: Coord = notch.try_into().ok()?;
- let mut spare = ((rect.0[1] - rect.0[0]).ok()?
+ let mut spare = ((rect.br() - rect.tl()).ok()?
- ppiece_use_size).ok()?;
- for s in &mut spare.0 { *s = max(*s,1) }
+ for s in &mut spare.coords { *s = max(*s,1) }
let fi = 0;
let gi = 1;
- let f_stride = max(ppiece_use_size.0[fi] / 4, 1);
- let g_stride = max(ppiece_use_size.0[gi] / 3, 1);
- let f_count = max(spare.0[fi] / f_stride, 1);
- let g_count = max(spare.0[gi] / g_stride, 1);
+ let f_stride = max(ppiece_use_size.coords[fi] / 4, 1);
+ let g_stride = max(ppiece_use_size.coords[gi] / 3, 1);
+ let f_count = max(spare.coords[fi] / f_stride, 1);
+ let g_count = max(spare.coords[gi] / g_stride, 1);
let mut f_num = notch % f_count;
let g_num = notch / f_count;
if g_num % 2 != 0 { f_num = f_count - 1 - f_num }
- let f_coord = rect.0[1].0[fi] - ppiece_use_size.0[fi] / 2 -
+ let f_coord = rect.br().coords[fi] - ppiece_use_size.coords[fi] / 2 -
f_stride * f_num;
- let g_coord = rect.0[0].0[gi] + ppiece_use_size.0[gi] / 2 +
+ let g_coord = rect.tl().coords[gi] + ppiece_use_size.coords[gi] / 2 +
if g_num < g_count {
g_stride * g_num
- } else if g_num < spare.0[gi] {
+ } else if g_num < spare.coords[gi] {
g_num
} else {
- spare.0[gi] - 1
+ spare.coords[gi] - 1
};
trace_dbg!("placement", spare,
f_stride, f_count, f_num, f_coord,
g_stride, g_count, g_num, g_coord);
- let mut pos = PosC([0,0]);
- pos.0[fi] = f_coord;
- pos.0[gi] = g_coord;
+ let mut pos = PosC::zero();
+ pos.coords[fi] = f_coord;
+ pos.coords[gi] = g_coord;
pos
}))().unwrap_or_else(||{
rect.middle()
let ilk = ilk.borrow();
if let Some(ilk) = ioccults.ilks.get(ilk); // expected, really
if let Ok::<_,IE>(bbox) = ilk.p_occ.bbox_approx(); // expected, really
- if let Ok(size) = bbox[1] - bbox[0]; // expected, really
+ if let Ok(size) = bbox.br() - bbox.tl(); // expected, really
then { occ.ppiece_use_size = size; }
};
let notch = occ.notches
region,
occulter,
views,
- ppiece_use_size: PosC([0,0]),
+ ppiece_use_size: PosC::zero(),
notches: default(),
};
debug!("creating occultation {:?}", &occultation);
}
#[throws(SvgE)]
-pub fn svg_rectangle_path(PosC([x,y]): PosC<f64>) -> Html {
+pub fn svg_rectangle_path(PosC{coords: [x,y]}: PosC<f64>) -> Html {
Html(format!("M {} {} h {} v {} h {} z",
-x*0.5, -y*0.5, x, y, -x))
}
to self.outline {
fn outline_path(&self, scale: f64) -> Result<Html,IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>,IE>;
- fn bbox_approx(&self) -> Result<[Pos;2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}
}
}
else { "black" }
};
let fontsz = 4.;
- let PosC([x,y]) = {
+ let PosC{ coords: [x,y] } = {
use piece_specs::PieceLabelPlace::*;
let inout = match self.place {
BottomLeft | TopLeft => 1.,
BottomLeftOutside | TopLeftOutside => -1.,
};
- let eff_size = (outline.xy - PosC([2., inout * 2.]))?;
+ let eff_size = (outline.xy - PosC::new(2., inout * 2.))?;
let mut pos = (eff_size * -0.5)?;
- let y = &mut pos.0[1];
+ let y = &mut pos.coords[1];
*y += 0.5 * fontsz * inout;
match self.place {
BottomLeft | BottomLeftOutside => { *y *= -1. },
#[throws(SpecError)]
fn xy(&self) -> Pos {
match *self.size.as_slice() {
- [s,] => PosC([s,s]),
- [x,y] => PosC([x,y]),
+ [s,] => PosC::new(s,s),
+ [x,y] => PosC::new(x,y),
_ => throw!(SpecError::ImproperSizeSpec),
}
}
impl OutlineTrait for ItemOccultable { delegate! { to self.outline {
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
- fn bbox_approx(&self) -> Result<[Pos; 2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}}}
#[typetag::serde(name="Lib")]
impl OccultedPieceTrait for ItemOccultable {
pub struct ItemEnquiryData {
pub itemname: String,
pub f0desc: Html,
- pub f0bbox: [Pos; 2],
+ pub f0bbox: Rect,
}
impl ItemEnquiryData {
impl OutlineTrait for Item { delegate! { to self.outline {
fn outline_path(&self, scale: f64) -> Result<Html, IE>;
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
- fn bbox_approx(&self) -> Result<[Pos; 2], IE>;
+ fn bbox_approx(&self) -> Result<Rect, IE>;
}}}
impl FaceTransform {
Some((self.diam * 0.5) as Coord)
}
#[throws(IE)]
- fn bbox_approx(&self) -> [Pos;2] {
+ fn bbox_approx(&self) -> Rect {
let d = (self.diam * 0.5).ceil() as Coord;
- [PosC([-d,-d]), PosC([d, d])]
+ Rect{ corners: [PosC::new(-d,-d), PosC::new(d, d)]}
}
}
let offset = offset.try_map(
|c| c.floor().to_i32().ok_or(CoordinateOverflow)
)?;
- let rect = RectC(
+ let rect = RectC{ corners:
[-1,1].iter().map(|&signum| Ok::<_,CoordinateOverflow>({
(centre + (offset * signum)?)?
}))
.collect::<Result<ArrayVec<_>,_>>()?
.into_inner().unwrap()
- );
+ };
rect
}
}
#[throws(IE)]
fn thresh_dragraise(&self) -> Option<Coord> {
- let smallest: f64 = self.xy.0.iter().cloned()
+ let smallest: f64 = self.xy.coords.iter().cloned()
.map(OrderedFloat::from).min().unwrap().into();
Some((smallest * 0.5) as Coord)
}
#[throws(IE)]
- fn bbox_approx(&self) -> [Pos;2] {
+ fn bbox_approx(&self) -> Rect {
let pos: Pos = self.xy.map(
|v| ((v * 0.5).ceil()) as Coord
);
let neg = (-pos)?;
- [ neg, pos ]
+ Rect{ corners: [ neg, pos ] }
}
}
impl SquareDefn {
#[throws(LibraryLoadError)]
fn get(group: &GroupData) -> Rectangle {
- Rectangle { xy: PosC(
+ Rectangle { xy: PosC{ coords:
match group.d.size.as_slice() {
&[s] => [s,s],
s if s.len() == 2 => s.try_into().unwrap(),
size => throw!(LLE::WrongNumberOfSizeDimensions
{ got: size.len(), expected: [1,2]}),
}
- )}
+ }}
}
}
self.0
.values()
.any(
- |r| r.contains(PosC([x,y]))
+ |r| r.contains(PosC::new(x,y))
)
}
}
})?;
(||{
let vec: ndarray::Array1<f64> =
- posg.0.iter()
+ posg.coords.iter()
.cloned()
.map(|v| v as f64)
.chain(iter::once(1.))
);
let x = a("x")?;
let y = a("y")?;
- Ok::<_,AE>(PosC([x,y]))
+ Ok::<_,AE>(PosC::new(x,y))
})()
.with_context(|| self.pieceid.to_owned())
.context("read position of piece out of x,y attributes")?
w.action_chain()
.move_pos(&pawn)?
.click_and_hold()
- .move_w(&w, (hand_posg + PosC([20,0]))?)?
+ .move_w(&w, (hand_posg + PosC::new(20,0))?)?
.release()
.perform()?;
w.synch()?;
let mut w = su.w(&self.alice)?;
let p = w.find_piece(pc)?;
let start = p.posg()?;
- let end = |d| { let mut e = start; e.0[1] = table_size.0[1] + d; e };
+ let end = |d| { let mut e = start; e.coords[1] = table_size.y() + d; e };
let try_end = end(10);
let exp_end = end(0);
w.action_chain()
{
let mut w = su.w(&self.alice)?;
w.action_chain()
- .move_w(&w, PosC([10,10]))?
+ .move_w(&w, PosC::new(10,10))?
.click()
.release()
.perform()
let mut w = su.w(window)?;
let p = w.find_piece(pc)?;
let start = p.posg()?;
- let try_end = (start + PosC([dx, 0]))?;
+ let try_end = (start + PosC::new(dx, 0))?;
let (sx,sy) = w.posg2posw(start)?;
w.action_chain()