(context, screen)
| 8 | // For higher-level drawing functions, go to 'colour.js' |
| 9 | export const SCREEN_BORDER_WIDTH = 2; |
| 10 | export const drawBorder = (context, screen) => { |
| 11 | const { colour, corners } = screen; |
| 12 | // fillBackground(context, { colour: Colour.Black, corners }); |
| 13 | |
| 14 | const canvasCornerPositions = getCanvasPositions(context, corners); |
| 15 | const [a, b, c, d] = canvasCornerPositions; |
| 16 | |
| 17 | let { depth } = screen; |
| 18 | |
| 19 | // console.log(depth); |
| 20 | const overflow = depth - 500; |
| 21 | if (overflow > 0) { |
| 22 | const alpha = 1 - overflow / 500; |
| 23 | if (alpha < 0.01) return; |
| 24 | context.globalAlpha = 1 - overflow / 500; |
| 25 | } |
| 26 | // if (context.globalAlpha <= 0.1) return; |
| 27 | context.beginPath(); |
| 28 | context.moveTo(...a); |
| 29 | context.lineTo(...b); |
| 30 | context.lineTo(...d); |
| 31 | context.lineTo(...c); |
| 32 | context.closePath(); |
| 33 | |
| 34 | // context.fillStyle = "#232940aa"; |
| 35 | context.fillStyle = "#232940"; |
| 36 | context.fill(); |
| 37 | |
| 38 | context.lineWidth = SCREEN_BORDER_WIDTH; |
| 39 | context.strokeStyle = colour.hex; |
| 40 | // context.strokeStyle = "#232940aa"; |
| 41 | context.stroke(); |
| 42 | |
| 43 | if (screen.parent) { |
| 44 | // const canvasParentPositions = getCanvasPositions( |
| 45 | // context, |
| 46 | // screen.parent.corners |
| 47 | // ); |
| 48 | // const [pa] = canvasParentPositions; |
| 49 | // context.beginPath(); |
| 50 | // context.moveTo(...pa); |
| 51 | // context.lineTo(...a); |
| 52 | // context.closePath(); |
| 53 | // context.lineWidth = SCREEN_BORDER_WIDTH; |
| 54 | // context.strokeStyle = "white"; |
| 55 | // context.stroke(); |
| 56 | } |
| 57 | |
| 58 | if (window.debugCorners) { |
| 59 | context.fillStyle = "#ffffff99"; |
| 60 | context.font = `${30 / devicePixelRatio}px Arial`; |
| 61 | context.fillText( |
| 62 | `${corners[0][0].toFixed(2)}, ${corners[0][1].toFixed(2)}`, |
| 63 | a[0] + 10 / devicePixelRatio, |
| 64 | a[1] - 10 / devicePixelRatio |
| 65 | ); |
| 66 | |
| 67 | context.fillText( |
no test coverage detected