import Toybox.Lang; import Toybox.Graphics; // Draws a top-down padel court centered at (cx, cy) and a yellow serve ball // in the given quadrant. Half-width HW and half-height HH keep it inside the // central band of the round screen. class CourtRenderer { private const HW = 60; // half court width (px) private const HH = 78; // half court height (px) private const BALL_R = 6; public function draw(dc as Graphics.Dc, cx as Number, cy as Number, quadrant as Number, showBall as Boolean) as Void { var left = cx - HW; var top = cy - HH; dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT); dc.setPenWidth(2); dc.drawRectangle(left, top, 2 * HW, 2 * HH); // outer court dc.drawLine(cx, top, cx, cy + HH); // center service line dc.setPenWidth(1); dc.drawLine(left, cy - HH / 2, left + 2 * HW, cy - HH / 2); // upper service line dc.drawLine(left, cy + HH / 2, left + 2 * HW, cy + HH / 2); // lower service line dc.setPenWidth(3); dc.drawLine(left, cy, left + 2 * HW, cy); // net if (showBall) { var pos = _ballPos(quadrant, cx, cy); dc.setColor(Graphics.COLOR_YELLOW, Graphics.COLOR_TRANSPARENT); dc.fillCircle(pos[0], pos[1], BALL_R); } } private function _ballPos(quadrant as Number, cx as Number, cy as Number) as Array { var dx = HW / 2; var dy = HH / 2; if (quadrant == QUAD_BOTTOM_RIGHT) { return [cx + dx, cy + dy]; } if (quadrant == QUAD_BOTTOM_LEFT) { return [cx - dx, cy + dy]; } if (quadrant == QUAD_UPPER_LEFT) { return [cx - dx, cy - dy]; } return [cx + dx, cy - dy]; // QUAD_UPPER_RIGHT } }