diff --git a/src/components/Recognizer/Recognizer.tsx b/src/components/Recognizer/Recognizer.tsx index 52dffcd..3e2f1a3 100644 --- a/src/components/Recognizer/Recognizer.tsx +++ b/src/components/Recognizer/Recognizer.tsx @@ -35,6 +35,47 @@ export default class Recognizer extends React.Component= gridW || rd < 0 || + cd >= gridH || cd < 0 || + g[rd][cd] !== key[k]) + break; + + rd += x[dir]; + cd += y[dir]; + } + + if (k === key.length) { + cd += Math.sign(col - cd); + rd += Math.sign(row - rd); + + return { + key, + selection: { + start: {x: col, y: row}, + end: {x: cd, y: rd}, + } + } + } + } + } + handleTakePhoto(files: any[], _: any[]): void { const image = document.createElement('img'); image.src = URL.createObjectURL(files[0]); @@ -97,16 +138,29 @@ export default class Recognizer extends React.Component {