draw booleans as 0-1

This commit is contained in:
themancalledjakob 2024-04-12 19:15:01 +02:00
parent 86d3e07f6f
commit 7874d3c291

View file

@ -66,7 +66,7 @@ const BasicKeyframedTrack: React.VFC<{
const extremumSpace: ExtremumSpace = useMemo(() => {
const extremums =
propConfig.type === 'number'
propConfig.type === 'number' || propConfig.type === 'boolean'
? calculateScalarExtremums(trackData.keyframes, propConfig)
: calculateNonScalarExtremums(trackData.keyframes)
@ -109,7 +109,7 @@ const BasicKeyframedTrack: React.VFC<{
layoutP={layoutP}
sheetObject={sheetObject}
trackId={trackId}
isScalar={propConfig.type === 'number'}
isScalar={propConfig.type === 'number' || propConfig.type === 'boolean'}
key={kf.id}
extremumSpace={cachedExtremumSpace.current}
color={color}
@ -146,12 +146,16 @@ function calculateScalarExtremums(
}
keyframes.forEach((cur, i) => {
const curVal = valueInProp(cur.value, propConfig) as number
const cv = typeof cur.value === 'boolean' ? (cur.value ? 1 : 0) : cur.value
const curVal = valueInProp(cv, propConfig) as number
check(curVal)
if (!cur.connectedRight) return
const next = keyframes[i + 1]
if (!next) return
const diff = (typeof next.value === 'number' ? next.value : 1) - curVal
const nv =
typeof next.value === 'boolean' ? (next.value ? 1 : 0) : next.value
const diff = (typeof nv === 'number' ? nv : 1) - curVal
check(curVal + cur.handles[3] * diff)
check(curVal + next.handles[1] * diff)
})