alignVertically/Horizontally (#106)

This commit is contained in:
Kurt Hutten
2023-04-06 12:45:56 +10:00
committed by GitHub
parent db5220467b
commit 52b2e26ac5
5 changed files with 87 additions and 32 deletions

View File

@ -1,16 +1,17 @@
import { TransformCallback } from './stdTypes'
import { Selections, toolTips, TooTip, Selection } from '../../useStore'
import {
BinaryPart,
CallExpression,
Program,
Value,
BinaryPart,
VariableDeclarator,
} from '../abstractSyntaxTree'
import {
getNodeFromPath,
getNodeFromPathCurry,
getNodePathFromSourceRange,
isValueZero,
} from '../queryAst'
import {
createBinaryExpression,
@ -252,14 +253,17 @@ const setHorzVertDistanceCreateNode =
getArgLiteralVal(args?.[index]) - (referencedSegment?.to?.[index] || 0),
2
)
const makeBinExp = createBinaryExpressionWithUnary([
let finalValue: Value = createBinaryExpressionWithUnary([
createSegEnd(referenceSegName, !index),
(forceValueUsedInTransform as BinaryPart) ||
createLiteral(valueUsedInTransform),
])
if (isValueZero(forceValueUsedInTransform)) {
finalValue = createSegEnd(referenceSegName, !index)
}
return createCallWrapper(
'lineTo',
!index ? [makeBinExp, args[1]] : [args[0], makeBinExp],
!index ? [finalValue, args[1]] : [args[0], finalValue],
tag,
valueUsedInTransform
)