vcs: fixed test with null Context2D
This commit is contained in:
parent
44271fe9b8
commit
1c0b3e2fdd
|
@ -17,9 +17,9 @@ jobs:
|
||||||
node-version: [16.x]
|
node-version: [16.x]
|
||||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
|
@ -887,7 +887,7 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
|
||||||
if (!this.isRunning() && isRaster(this.machine) && this.machine.getRasterCanvasPosition) {
|
if (!this.isRunning() && isRaster(this.machine) && this.machine.getRasterCanvasPosition) {
|
||||||
const {x,y} = this.machine.getRasterCanvasPosition();
|
const {x,y} = this.machine.getRasterCanvasPosition();
|
||||||
if (x >= 0 || y >= 0) {
|
if (x >= 0 || y >= 0) {
|
||||||
const ctx = this.video.getContext();
|
const ctx = this.video?.getContext();
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
drawCrosshair(ctx, x, y, 1);
|
drawCrosshair(ctx, x, y, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,7 @@ export class VectorVideo extends RasterVideo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function drawCrosshair(ctx:CanvasRenderingContext2D, x:number, y:number, width:number) {
|
export function drawCrosshair(ctx:CanvasRenderingContext2D, x:number, y:number, width:number) {
|
||||||
|
if (!ctx?.setLineDash) return; // for unit testing
|
||||||
ctx.fillStyle = 'rgba(0,0,0,0.25)';
|
ctx.fillStyle = 'rgba(0,0,0,0.25)';
|
||||||
ctx.fillRect(x-2, 0, 5, 32767);
|
ctx.fillRect(x-2, 0, 5, 32767);
|
||||||
ctx.fillRect(0, y-2, 32767, 5);
|
ctx.fillRect(0, y-2, 32767, 5);
|
||||||
|
|
|
@ -438,8 +438,10 @@ class VCSPlatform extends BasePlatform {
|
||||||
updateVideoDebugger() {
|
updateVideoDebugger() {
|
||||||
const {x,y} = this.getRasterCanvasPosition();
|
const {x,y} = this.getRasterCanvasPosition();
|
||||||
if (x >= 0 || y >= 0) {
|
if (x >= 0 || y >= 0) {
|
||||||
const ctx = this.canvas.getContext('2d');
|
const ctx = this.canvas?.getContext('2d');
|
||||||
drawCrosshair(ctx, x, y, 2);
|
if (ctx) {
|
||||||
|
drawCrosshair(ctx, x, y, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue