-
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function featureDetect(): boolean { | ||
const canvasMethods = [ | ||
"fillStyle", | ||
"fillRect", | ||
"filter", | ||
"translate", | ||
"rotate", | ||
"drawImage", | ||
"strokeStyle", | ||
"lineWidth", | ||
"strokeRect", | ||
]; | ||
|
||
// check CanvasRenderingContext2D.prototype | ||
const canvasProto = CanvasRenderingContext2D.prototype; | ||
for (const method of canvasMethods) { | ||
if (!(method in canvasProto)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { type ScanConfig, defaultConfig, colorspaces } from "./types"; | ||
export { CanvasScanner } from "./scanner"; | ||
export { featureDetect } from "./feature-detect"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<CanvasScanView v-if="supportCanvasScan" /> | ||
<MagicaScanView v-else /> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { featureDetect } from "@/utils/scan-renderer/canvas-scan"; | ||
import CanvasScanView from "./CanvasScanView.vue"; | ||
import MagicaScanView from "./MagicaScanView.vue"; | ||
const supportCanvasScan = featureDetect(); | ||
</script> |