From: Ian Jackson Date: Thu, 25 Mar 2021 16:38:13 +0000 (+0000) Subject: script: break out piece_xy X-Git-Tag: otter-0.5.0~416 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c2d7a2cd0892d3faccef6e114d30116ff9a14e82;p=otter.git script: break out piece_xy Signed-off-by: Ian Jackson --- diff --git a/templates/script.ts b/templates/script.ts index 96b8d1eb..2360b2f9 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -676,11 +676,17 @@ var dcy : number | null; const DRAGTHRESH = 5; +function piece_xy(p: PieceInfo): [number, number] { + return [ parseFloat(p.uelem.getAttributeNS(null,"x")!), + parseFloat(p.uelem.getAttributeNS(null,"y")!) ]; +} + function drag_add_piece(piece: PieceId, p: PieceInfo) { + let [dox, doy] = piece_xy(p); drag_pieces.push({ piece: piece, - dox: parseFloat(p.uelem.getAttributeNS(null,"x")!), - doy: parseFloat(p.uelem.getAttributeNS(null,"y")!), + dox: dox, + doy: doy, }); }