ISSUE-045 - Chyron Body - Added the outline to the chyron body.

It's not a perfect emulation (it fades out rather than runs out with a tail) but I'm very happy with it.
Also updated the wipe animation to take advantage of map().
This commit is contained in:
Kyle Geib committed 2022-02-11 12:24:31 -05:00
1 parent 462ea4852b
commit e6312f67e0
4 files changed
+110 -25

No files matched your search

@@ -5,6 +5,7 @@ import { BGChyronDriver, BGChyronSubMode, OpenState } from "../../../../types/st
import { Fraction } from "../../../../types/style"; import { Fraction } from "../../../../types/style";
import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice"; import { clearChyrons } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
import { theme } from "../../../../shared/theme"; import { theme } from "../../../../shared/theme";
import { outlineClipPath } from "../../../../utils/styling";
import { DriverNumber } from "../../Common/DriverNumber"; import { DriverNumber } from "../../Common/DriverNumber";
import { AngledFlag } from "../../Common/AngledFlag"; import { AngledFlag } from "../../Common/AngledFlag";
@@ -13,7 +14,7 @@ import { DriverPortrait } from "../../Common/DriverPortrait";
import { import {
AnimatedBaseContainer, AnimatedBaseContainer,
BaseLayout, BaseLayout,
BaseOutline, AnimatedBaseOutline,
BaseBlack, BaseBlack,
BaseBackgroundColor, BaseBackgroundColor,
FirstName, FirstName,
@@ -46,6 +47,7 @@ export function ChyronDriver({
: [0, 0]; : [0, 0];
const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData; const { car, flagMode, showPosFlag, showDriverNumber, showPortrait } = chyronData;
const flagProps = flagMode === "country" const flagProps = flagMode === "country"
? { flagMode, flag: car.driver.nationality } ? { flagMode, flag: car.driver.nationality }
: flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined; : flagMode === "team" ? { flagMode, flag: car.driver.team.id } : undefined;
@@ -63,6 +65,12 @@ export function ChyronDriver({
}, },
}); });
const { outlineClipPathProgress } = useSpring({
outlineClipPathProgress: openState !== 0 ? 1 : 0,
config: { duration: 500 * DDM },
delay: 0,
});
const teamColor = theme.colors.teams[car.driver.team.id]; const teamColor = theme.colors.teams[car.driver.team.id];
return ( return (
@@ -71,12 +79,27 @@ export function ChyronDriver({
height={baseHeight} height={baseHeight}
style={containerFadeAwaySpring} style={containerFadeAwaySpring}
> >
<BaseOutline <AnimatedBaseOutline
open={openState !== 0} open={openState !== 0}
startThickness={5}
endThickness={1}
startColor="#ffffffff"
endColor="#ffffff00"
transitionProps={[{ transitionProps={[{
property: "outline", property: "outline",
duration: 1167 * DDM, duration: 1167 * DDM,
}]} }]}
style={{
clipPath: outlineClipPathProgress.to(progress => {
const coordinates = outlineClipPath(
baseWidth,
baseHeight,
progress,
5,
);
return `polygon(${coordinates.map(([x, y]) => `${x}px ${y}px`).join(", ")})`;
}),
}}
/> />
<BaseBlack <BaseBlack
open={openState !== 0} open={openState !== 0}
@@ -31,16 +31,22 @@ const BaseShape = styled.div`
border-bottom-right-radius: 11px; border-bottom-right-radius: 11px;
`; `;
export const BaseOutline = styled(BaseShape)<TransitionProps>` type AnimatedBaseOutlineProps = TransitionProps & {
startThickness: Px,
endThickness: Px,
startColor: string,
endColor: string,
};
export const AnimatedBaseOutline = animated(styled(BaseShape)<AnimatedBaseOutlineProps>`
width: 100%; width: 100%;
opacity: ${({ open }) => open ? 1 : 0}; opacity: ${({ open }) => open ? 1 : 0};
outline: ${({ open }) => open outline: ${({ open, startThickness, endThickness, startColor, endColor }) => open
? "2px solid #ffffff00" ? `${endThickness}px solid ${endColor}`
: "5px solid #ffffffff"}; : `${startThickness}px solid ${startColor}`};
${({ transitionProps }) => commonTransition(transitionProps)} ${({ transitionProps }) => commonTransition(transitionProps)}
`; `);
BaseOutline.displayName = "BaseOutline"; AnimatedBaseOutline.displayName = "AnimatedBaseOutline";
export const BaseBlack = styled(BaseShape)<TransitionProps>` export const BaseBlack = styled(BaseShape)<TransitionProps>`
opacity: ${({ open }) => open ? 1 : 0.1}; opacity: ${({ open }) => open ? 1 : 0.1};
@@ -1,4 +1,4 @@
import { useSpring, animated } from "@react-spring/web"; import { useSpring, animated, easings } from "@react-spring/web";
import useMeasure from "react-use-measure"; import useMeasure from "react-use-measure";
import { AnimatedVenetianBlindsFilter, VenetianBlindsFilter } from "./styles"; import { AnimatedVenetianBlindsFilter, VenetianBlindsFilter } from "./styles";
@@ -52,7 +52,10 @@ export const VenetianBlindsTransition = (
const { wipe } = useSpring({ const { wipe } = useSpring({
wipe: visible ? 1 : 0, wipe: visible ? 1 : 0,
config: { duration: wipeDuration }, config: {
duration: wipeDuration,
easing: easings.easeInOutQuint,
},
delay: 0 + delay, delay: 0 + delay,
}); });
@@ -73,14 +76,14 @@ export const VenetianBlindsTransition = (
style={{ style={{
opacity, opacity,
clipPath: wipe.to(wipeProgress => { clipPath: wipe.to(wipeProgress => {
const [a1, a2, b1, b2, c1, c2] = wipeCustomDegClip( const coordinates = wipeCustomDegClip(
childWidth, childWidth,
childHeight, childHeight,
wipeProgress, wipeProgress,
wipeStartingCorner, wipeStartingCorner,
wipeAngle, wipeAngle,
); );
return `polygon(${a1}px ${a2}px, ${b1}px ${b2}px, ${c1}px ${c2}px)`; return `polygon(${coordinates.map(([x, y]) => `${x}px ${y}px`).join(", ")})`;
}), }),
}} }}
ref={childRef} ref={childRef}
+66 -13
View File
@@ -30,33 +30,33 @@ export function wipeCustomDegClip(
progress: Fraction, progress: Fraction,
startingCorner: Corner, startingCorner: Corner,
degrees: number, degrees: number,
): [Px, Px, Px, Px, Px, Px] { ): [[Px, Px], [Px, Px], [Px, Px]] {
const tangent = Math.tan(clamp(degrees, 0.01, 90) * Math.PI / 180); const tangent = Math.tan(clamp(degrees, 0.01, 90) * Math.PI / 180);
switch (startingCorner) { switch (startingCorner) {
case "topLeft": case "topLeft":
return [ return [
0, 0, [0, 0],
(width + height / tangent) * progress, 0, [(width + height / tangent) * progress, 0],
0, (height + width * tangent) * progress , [0, (height + width * tangent) * progress ],
]; ];
case "topRight": case "topRight":
return [ return [
width, 0, [width, 0],
width, (height + width * tangent) * progress, [width, (height + width * tangent) * progress],
width - (width + height / tangent) * progress, 0, [width - (width + height / tangent) * progress, 0],
]; ];
case "bottomRight": case "bottomRight":
return [ return [
width, height, [width, height],
width, height - (height + width * tangent) * progress, [width, height - (height + width * tangent) * progress],
width - (width + height / tangent) * progress, height, [width - (width + height / tangent) * progress, height],
]; ];
case "bottomLeft": case "bottomLeft":
return [ return [
0, height, [0, height],
0, height - (height + width * tangent) * progress, [0, height - (height + width * tangent) * progress],
(width + height / tangent) * progress, height, [(width + height / tangent) * progress, height],
]; ];
} }
} }
@@ -70,3 +70,56 @@ export function commonTransition(propsArray: TransitionArgs[]) {
+ ";" + ";"
); );
} }
export function outlineClipPath(
width: Px,
height: Px,
progress: Fraction,
outlineThickness: Px,
): [[Px, Px], [Px, Px], [Px, Px], [Px, Px], [Px, Px], [Px, Px]] {
const travelDistance = width * 2 + height;
const pt1End = width / travelDistance;
const pt2End = (width + height) / travelDistance;
// Part 1: Reveal the bottom line.
if (progress <= pt1End) {
const x = width * progress / pt1End;
return [
[0, height],
[0, height],
[0, height],
[x, height],
[x, height + outlineThickness],
[0, height + outlineThickness],
];
// Part 2: Reveal the right line.
} else if (progress > pt1End && progress <= pt2End) {
const y = height - (height + outlineThickness) * ((progress - pt1End) / (pt2End - pt1End));
return [
[0, height],
[width - 10, height],
[width, y],
[width + outlineThickness, y],
[width + outlineThickness, height + outlineThickness],
[0, height + outlineThickness],
];
// Part 3: Reveal the top line.
} else {
const x = width - width * ((progress - pt2End) / (1 - pt2End));
return [
[0, height],
[x - 10, height],
[x, -outlineThickness],
[width + outlineThickness, -outlineThickness],
[width + outlineThickness, height + outlineThickness],
[0, height + outlineThickness],
];
}
// return [
// ]
}