From c2d7a2cd0892d3faccef6e114d30116ff9a14e82 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 25 Mar 2021 16:38:13 +0000 Subject: [PATCH] script: break out piece_xy Signed-off-by: Ian Jackson --- templates/script.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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, }); } -- 2.30.2