summaryrefslogtreecommitdiff
path: root/frontend/app/views/tile/tile.utils.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-03-31 17:37:40 +0200
committerJules Laplace <julescarbon@gmail.com>2021-03-31 17:37:40 +0200
commitcda9c115283be8e4e224f6036ba07e5eca243289 (patch)
treed0b150bf108813873c7b59cc9f9bd9c00ea3eba7 /frontend/app/views/tile/tile.utils.js
parenta6793f922991d326eeb33cf08b245863218eaef7 (diff)
refactor tile forms into own files. add full-width marquee support
Diffstat (limited to 'frontend/app/views/tile/tile.utils.js')
-rw-r--r--frontend/app/views/tile/tile.utils.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/frontend/app/views/tile/tile.utils.js b/frontend/app/views/tile/tile.utils.js
index 46d7764..043732b 100644
--- a/frontend/app/views/tile/tile.utils.js
+++ b/frontend/app/views/tile/tile.utils.js
@@ -3,6 +3,13 @@ export const generateTransform = (tile, box, bounds, videoBounds) => {
if (is_tiled) {
return 'translateZ(0)'
}
+
+ const is_full_width = (tile.type === 'text' && tile.settings.is_marquee)
+
+ if (is_full_width) {
+ x = 0
+ }
+
if (box) {
x += box.dx
y += box.dy
@@ -77,4 +84,23 @@ export const unitsDimension = (tile, dimension, bounds, videoBounds) => {
export const videoUnits = (value, bounds, videoBounds) => (
Math.round(value / videoBounds.width * bounds.width) + 'px'
-) \ No newline at end of file
+)
+
+export const hexToRgb = (hex) => {
+ if (!hex) {
+ return null
+ }
+ let result;
+ if (hex.length === 7) {
+ result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
+ } else if (hex.length === 4) {
+ result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})$/i.exec(hex)
+ } else {
+ return { r: 255, g: 0, b: 255 }
+ }
+ return result ? {
+ r: parseInt(result[1], 16),
+ g: parseInt(result[2], 16),
+ b: parseInt(result[3], 16)
+ } : null
+} \ No newline at end of file