atem-connection
Advanced tools
Comparing version 3.0.0-nightly-feat-multiview-labels-20220321-223651-c91eb39.0 to 3.0.0-nightly-feat-multiview-labels-20220323-224359-f8b44bf.0
@@ -8,3 +8,4 @@ "use strict"; | ||
* Colour lookup table for converting 8bit grey to the atem encoding | ||
* Note: not every colour is available, so values have been extrapolated to fill in the gaps | ||
* Note: not every colour is available, so values have been extrapolated to fill in the gaps. | ||
* Also the background colour has been filled in for lower values, to ensure that the text doesnt accidentally remove the background | ||
*/ | ||
@@ -23,3 +24,11 @@ const colourLookupTable = [ | ||
]; | ||
const Res4K = { | ||
function fillResolutionSpec(spec) { | ||
return { | ||
...spec, | ||
cornerRight: spec.corner.map((buf) => { | ||
return Buffer.from(buf).reverse(); | ||
}), | ||
}; | ||
} | ||
const Res4K = fillResolutionSpec({ | ||
width: 640, | ||
@@ -31,4 +40,18 @@ height: 100, | ||
fontHeight: 46, | ||
}; | ||
const Res1080 = { | ||
borderColour: 0x05, | ||
corner: [ | ||
Buffer.from([0, 0, 0, 0, 0, 0, 223, 2, 162, 220, 20]), | ||
Buffer.from([0, 0, 0, 0, 223, 195, 20, 5, 5, 5, 5]), | ||
Buffer.from([0, 0, 0, 7, 3, 5, 5, 110, 141, 124, 29]), | ||
Buffer.from([0, 0, 7, 220, 5, 200, 97, 14, 14, 14, 14]), | ||
Buffer.from([0, 223, 3, 5, 209, 29, 14, 14, 14, 14, 14]), | ||
Buffer.from([0, 219, 5, 200, 29, 14, 14, 14, 14, 14, 14]), | ||
Buffer.from([223, 20, 5, 97, 14, 14, 14, 14, 14, 14, 14]), | ||
Buffer.from([2, 5, 110, 14, 14, 14, 14, 14, 14, 14, 14]), | ||
Buffer.from([162, 5, 141, 14, 14, 14, 14, 14, 14, 14, 14]), | ||
Buffer.from([220, 5, 124, 14, 14, 14, 14, 14, 14, 14, 14]), | ||
Buffer.from([20, 5, 29, 14, 14, 14, 14, 14, 14, 14, 14]), | ||
], | ||
}); | ||
const Res1080 = fillResolutionSpec({ | ||
width: 320, | ||
@@ -40,4 +63,13 @@ height: 50, | ||
fontHeight: 26, | ||
}; | ||
const Res720 = { | ||
borderColour: 0x05, | ||
corner: [ | ||
Buffer.from([0, 0, 1, 229, 230, 20]), | ||
Buffer.from([0, 7, 158, 5, 5, 5]), | ||
Buffer.from([1, 158, 5, 23, 37, 101]), | ||
Buffer.from([229, 5, 23, 29, 14, 14]), | ||
Buffer.from([230, 5, 37, 14, 14, 14]), | ||
Buffer.from([20, 5, 101, 14, 14, 14]), | ||
], | ||
}); | ||
const Res720 = fillResolutionSpec({ | ||
width: 320, | ||
@@ -48,7 +80,14 @@ height: 40, | ||
yPadTop: 4, | ||
fontHeight: 16, | ||
}; | ||
fontHeight: 17, | ||
borderColour: 170, | ||
corner: [ | ||
Buffer.from([0, 0, 160, 169]), | ||
Buffer.from([0, 165, 165, 169]), | ||
Buffer.from([160, 165, 56, 14]), | ||
Buffer.from([169, 169, 14, 14]), | ||
], | ||
}); | ||
// const transparentColour = 0 // encoded value | ||
const bgColour = colourLookupTable[0]; // 'background' value | ||
const borderColour = 0x05; // encoded value | ||
// const borderColour = 0x05 // encoded value | ||
function calculateWidthAndTrimText(face, str, maxWidth) { | ||
@@ -87,10 +126,23 @@ let trimmedStr = ''; // currently measured string | ||
if (isBorder) { | ||
drawHorizontalLine(y, 0, boundaryWidth, borderColour); | ||
drawHorizontalLine(y, 0, boundaryWidth, spec.borderColour); | ||
} | ||
else { | ||
drawHorizontalLine(y, 0, 2, borderColour); | ||
drawHorizontalLine(y, boundaryWidth - 2, 2, borderColour); | ||
drawHorizontalLine(y, 0, 2, spec.borderColour); | ||
drawHorizontalLine(y, boundaryWidth - 2, 2, spec.borderColour); | ||
drawHorizontalLine(y, 2, boundaryWidth - 4, bgColour); | ||
} | ||
} | ||
// Patch on the rounded corners | ||
for (let i = 0; i < spec.corner.length; i++) { | ||
const cornerBufferLeft = spec.corner[i]; | ||
const cornerBufferRight = spec.cornerRight[i]; | ||
const offsetTopLeft = (boundaryYOffset + i) * bufferWidth + boundaryXOffset; | ||
cornerBufferLeft.copy(buffer, offsetTopLeft); | ||
const offsetBottomLeft = (boundaryYOffset + boundaryHeight - i - 1) * bufferWidth + boundaryXOffset; | ||
cornerBufferLeft.copy(buffer, offsetBottomLeft); | ||
const offsetTopRight = offsetTopLeft + boundaryWidth - cornerBufferRight.length; | ||
cornerBufferRight.copy(buffer, offsetTopRight); | ||
const offsetBottomRight = offsetBottomLeft + boundaryWidth - cornerBufferRight.length; | ||
cornerBufferRight.copy(buffer, offsetBottomRight); | ||
} | ||
const maxLeft = boundaryXOffset + spec.width + spec.xPad; | ||
@@ -97,0 +149,0 @@ let charLeft = boundaryXOffset + spec.xPad; |
{ | ||
"name": "atem-connection", | ||
"version": "3.0.0-nightly-feat-multiview-labels-20220321-223651-c91eb39.0", | ||
"version": "3.0.0-nightly-feat-multiview-labels-20220323-224359-f8b44bf.0", | ||
"description": "Typescript Node.js library for connecting with an ATEM switcher.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1281731
13296