mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-04-14 23:37:04 +00:00
vcs: fixed test with null Context2D
This commit is contained in:
parent
44271fe9b8
commit
1c0b3e2fdd
4
.github/workflows/node.js.yml
vendored
4
.github/workflows/node.js.yml
vendored
@ -17,9 +17,9 @@ jobs:
|
||||
node-version: [16.x]
|
||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: 'npm'
|
||||
|
@ -887,7 +887,7 @@ export abstract class BaseMachinePlatform<T extends Machine> extends BaseDebugPl
|
||||
if (!this.isRunning() && isRaster(this.machine) && this.machine.getRasterCanvasPosition) {
|
||||
const {x,y} = this.machine.getRasterCanvasPosition();
|
||||
if (x >= 0 || y >= 0) {
|
||||
const ctx = this.video.getContext();
|
||||
const ctx = this.video?.getContext();
|
||||
if (ctx) {
|
||||
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) {
|
||||
if (!ctx?.setLineDash) return; // for unit testing
|
||||
ctx.fillStyle = 'rgba(0,0,0,0.25)';
|
||||
ctx.fillRect(x-2, 0, 5, 32767);
|
||||
ctx.fillRect(0, y-2, 32767, 5);
|
||||
|
@ -438,8 +438,10 @@ class VCSPlatform extends BasePlatform {
|
||||
updateVideoDebugger() {
|
||||
const {x,y} = this.getRasterCanvasPosition();
|
||||
if (x >= 0 || y >= 0) {
|
||||
const ctx = this.canvas.getContext('2d');
|
||||
drawCrosshair(ctx, x, y, 2);
|
||||
const ctx = this.canvas?.getContext('2d');
|
||||
if (ctx) {
|
||||
drawCrosshair(ctx, x, y, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user