Skip to content

Commit

Permalink
feat: Now works with both GDQ OBS green shades
Browse files Browse the repository at this point in the history
  • Loading branch information
markschwartzkopf committed Feb 26, 2022
1 parent 053472f commit 8a14962
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gdq-viewport-assign",
"version": "0.8.1",
"version": "0.9.0",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
12 changes: 8 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { icons } from './icons';

const autocropThreshold = 35;
const gdqGreen = [1, 128, 1];
const gdqGreen2 = [0, 255, 0];

let screenshotBase64 = '';
let connectedToOBS = false;
Expand Down Expand Up @@ -766,7 +767,7 @@ async function refreshViewportsDiv() {
.catch(obsError)
.then(() => {
subscribeToChanges();
arrangeViewportFeeds(currentSceneViewports[i])
arrangeViewportFeeds(currentSceneViewports[i]);
refreshViewportsDiv();
});
};
Expand Down Expand Up @@ -1429,9 +1430,12 @@ function compareToGreen(
y: number
): number {
const pixel = Array.from(ctx.getImageData(x, y, 1, 1).data);
return (
return Math.min(
Math.abs(pixel[0] - gdqGreen[0]) +
Math.abs(pixel[1] - gdqGreen[1]) +
Math.abs(pixel[2] - gdqGreen[2])
Math.abs(pixel[1] - gdqGreen[1]) +
Math.abs(pixel[2] - gdqGreen[2]),
Math.abs(pixel[0] - gdqGreen2[0]) +
Math.abs(pixel[1] - gdqGreen2[1]) +
Math.abs(pixel[2] - gdqGreen2[2])
);
}

0 comments on commit 8a14962

Please sign in to comment.