-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move source files around to more clearly seperate pipeline
- Loading branch information
Showing
15 changed files
with
130 additions
and
161 deletions.
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
File renamed without changes.
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,34 @@ | ||
export class BitMatrix { | ||
public static createEmpty(width: number, height: number) { | ||
return new BitMatrix(new Uint8ClampedArray(width * height), width); | ||
} | ||
|
||
public width: number; | ||
public height: number; | ||
private data: Uint8ClampedArray; | ||
|
||
constructor(data: Uint8ClampedArray, width: number) { | ||
this.width = width; | ||
this.height = data.length / width; | ||
this.data = data; | ||
} | ||
|
||
public get(x: number, y: number): boolean { | ||
if (x < 0 || x >= this.width || y < 0 || y >= this.height) { | ||
return false; | ||
} | ||
return !!this.data[y * this.width + x]; | ||
} | ||
|
||
public set(x: number, y: number, v: boolean) { | ||
this.data[y * this.width + x] = v ? 1 : 0; | ||
} | ||
|
||
public setRegion(left: number, top: number, width: number, height: number, v: boolean) { | ||
for (let y = top; y < top + height; y++) { | ||
for (let x = left; x < left + width; x++) { | ||
this.set(x, y, !!v); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
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
File renamed without changes.
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,43 @@ | ||
import {binarize} from "./binarizer"; | ||
import {BitMatrix} from "./bitmatrix"; | ||
import {decode} from "./decoder/decoder"; | ||
import {extract} from "./extractor"; | ||
import {locate} from "./locator"; | ||
|
||
export interface Point { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
export interface QRCode { | ||
binaryData: Uint8ClampedArray; | ||
text: string; | ||
encodingType: "numeric" | "alphanumeric" | "byte" | "structured_append" | "eci" | "kanji"; | ||
location: { | ||
topRightCorner: Point; | ||
topLeftCorner: Point; | ||
bottomRightCorner: Point; | ||
bottomLeftCorner: Point; | ||
|
||
topRightFinderPattern: Point; | ||
topLeftFinderPattern: Point; | ||
bottomLeftFinderPattern: Point; | ||
|
||
bottomRightAlignmentPattern?: Point; | ||
}; | ||
|
||
errorRate: number; // TODO is this the right field name? | ||
} | ||
|
||
// TODO - is this the name we want? | ||
export default function readQR(data: Uint8ClampedArray, width: number, height: number): QRCode | null { | ||
const binarized = binarize(data, width, height); | ||
const location = locate(binarized); | ||
if (!location) { | ||
return null; | ||
} | ||
const extracted = extract(binarized, location); | ||
const decoded = decode(extracted); | ||
|
||
return null; | ||
} |
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.