Compare commits

..

No commits in common. "ad1ba9c659c21874d63431ac62ceadb0d47de1df" and "d94e599c91f547cfefbe5bb75c872bfdc6a04d26" have entirely different histories.

3 changed files with 25 additions and 154 deletions

View File

@ -18,9 +18,9 @@ function handsInShortLine({ which, facing, wavy }: { which: ShortLinesPosition;
: [Hand.Right, { hand: wavy ? Hand.Left : Hand.Right, to: HandTo.DancerRight }]
]);
}
function handsInLine(args: { wavy: boolean, which: ShortLinesPosition | CirclePosition, facing?: Facing }) {
if (args.which instanceof ShortLinesPosition && (args.facing === Facing.Up || args.facing === Facing.Down)) {
return handsInShortLine({ wavy: args.wavy, which: args.which, facing: args.facing });
function handsInLine(args: { wavy: boolean } & ({ which: ShortLinesPosition, facing: Facing.Up | Facing.Down } | { which: CirclePosition })) {
if (args.which instanceof ShortLinesPosition && /*always true, type system limitation*/ 'facing' in args) {
return handsInShortLine(args);
} else {
return new Map<Hand, HandConnection>([
[Hand.Left, { hand: args.wavy ? Hand.Right : Hand.Left, to: HandTo.DancerLeft }],
@ -254,8 +254,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
beats: move.beats,
startPosition: { ...startPos, hands: undefined },
endPosition: { ...startPos, hands: undefined },
// TODO Not sure this is actually a good default...
movementPattern: { kind: SemanticAnimationKind.Linear, handsDuring: "None" },
movementPattern: { kind: SemanticAnimationKind.StandStill },
}]);
}
}
@ -277,13 +276,13 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
}
const startWhich = startPosAdjusted.which;
// TODO Can swing be across the set (top or bottom)?
const around = withPos.which.leftRightSide() === startWhich.leftRightSide()
? startWhich.leftRightSide()
: withPos.kind === PositionKind.Circle
? (startWhich instanceof CirclePosition && withPos.which.topBottomSide() === startWhich.topBottomSide()
? startWhich.topBottomSide()
: "Center")
: "Center";
const around = withPos.kind === PositionKind.Circle
? (withPos.which.leftRightSide() === startWhich.leftRightSide()
? startWhich.leftRightSide()
: startWhich instanceof CirclePosition && withPos.which.topBottomSide() === startWhich.topBottomSide()
? startWhich.topBottomSide()
: "Center")
: "Center";
return dancerFunc({ id, startPos: startPosAdjusted, withId, withPos, around });
});
@ -499,59 +498,21 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
});
case "do si do":
if (!move.parameters.shoulder) {
throw new Error("do si do by left shoulder is unsupported.");
}
let doSiDoEndKind: "Start" | "Swap" | "ShortLinesLeft" | "ShortLinesRight";
const doSiDoCircling = move.parameters.circling % 360;
if (doSiDoCircling === 360) {
doSiDoEndKind = "Start";
} else if (doSiDoCircling === 180) {
doSiDoEndKind = "Swap";
} else if (doSiDoCircling === 90) {
doSiDoEndKind = move.parameters.shoulder ? "ShortLinesLeft" : "ShortLinesRight";
} else if (doSiDoCircling === 270) {
doSiDoEndKind = move.parameters.shoulder ? "ShortLinesRight" : "ShortLinesLeft";
} else {
throw new Error("do si do by " + move.parameters.circling + " degrees is unsupported.");
}
return handleCirclePairedMove(move.parameters.who, ({ startPos, around, withPos }) => {
return handleCirclePairedMove(move.parameters.who, ({ startPos, around }) => {
// TODO Use other parameters?
const startingPos: SemanticPosition = {
const startAndEndPos = {
...startPos,
hands: undefined,
facing: around === "Center"
? Facing.CenterOfCircle
: around === CircleSide.Left || around === CircleSide.Right
? startPos.which.facingUpOrDown()
: startPos.which.facingAcross(),
? (startPos.which.isTop() ? Facing.Down : Facing.Up)
: (startPos.which.isLeft() ? Facing.Right : Facing.Left),
};
let endPos: SemanticPosition;
switch(doSiDoEndKind) {
case "Start":
endPos = startingPos;
break;
case "Swap":
endPos = { ...withPos, facing: startingPos.facing };
break;
case "ShortLinesLeft":
case "ShortLinesRight":
endPos = {
kind: PositionKind.ShortLines,
which: startPos.which.toShortLines(doSiDoEndKind === "ShortLinesLeft" ? Hand.Left : Hand.Right),
facing: startingPos.facing,
setOffset: startingPos.setOffset,
lineOffset: startingPos.lineOffset,
}
}
return combine([{
beats: move.beats,
startPosition: startingPos,
endPosition: endPos,
startPosition: startAndEndPos,
endPosition: startAndEndPos,
movementPattern: {
kind: SemanticAnimationKind.DoSiDo,
amount: move.parameters.circling,
@ -627,7 +588,6 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
facing: endFacing,
balance: undefined,
dancerDistance: undefined,
longLines: undefined,
hands: handsInLine({ wavy: false, which: endWhich, facing: endFacing }),
};
}
@ -2038,64 +1998,6 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
}], startAndEndPos);
})
case "Rory O'More":
if (move.parameters.who !== "everyone") {
throw new Error(move.move + " that doesn't include everyone is unsupported.");
}
// TODO Could be in long or short lines.
const roryDir = move.parameters.slide ? Hand.Left : Hand.Right;
const balBeats = move.parameters.bal ? move.beats / 2 : 0;
const balPartBeats = balBeats / 2;
const roryBeats = move.beats - balBeats;
return handleMove(({startPos}) => {
const isShortLines: boolean = startPos.kind === PositionKind.ShortLines;
const startingPos: SemanticPosition = {
...startPos,
hands: handsInLine({ wavy: true, which: startPos.which, facing: startPos.facing })
};
let endPos: SemanticPosition;
if (startPos.kind === PositionKind.ShortLines) {
if (startPos.facing !== Facing.Up && startPos.facing !== Facing.Down) {
throw new Error("To be in wavy lines, must be facing up or down, not " + startPos.facing);
}
const endWhich = startPos.which.shift(roryDir, startPos.facing);
endPos = {...startPos,
which: endWhich,
hands: handsInLine({ wavy: true, which: endWhich, facing: startPos.facing })
};
} else {
throw new Error(move.move + " is currently only supported in short lines.");
}
const maybeBalance: PartialLowLevelMove[] = (move.parameters.bal ? [
{
beats: balPartBeats,
endPosition: { ...startingPos, balance: roryDir === Hand.Left ? BalanceWeight.Left : BalanceWeight.Right },
movementPattern: { kind: SemanticAnimationKind.Linear },
},
{
beats: balPartBeats,
endPosition: { ...startingPos, balance: roryDir === Hand.Left ? BalanceWeight.Right : BalanceWeight.Left },
movementPattern: { kind: SemanticAnimationKind.Linear },
},
] : []);
return combine([...maybeBalance,
{
beats: roryBeats,
endPosition: endPos,
movementPattern: {
kind: SemanticAnimationKind.Linear,
minRotation: roryDir === Hand.Right ? +360 : -360,
handsDuring: "None",
},
}
], startingPos);
});
case "custom":
if (move.parameters.custom.includes("mirrored mad robin")) {
return handleCircleMove(({ id, startPos }) => {

View File

@ -95,22 +95,6 @@ export class CirclePosition {
][CirclePosition.enumValueToNumber(this.enumValue)];
}
public toShortLines(slideTo: Hand) : ShortLinesPosition {
return slideTo === Hand.Left
? [
ShortLinesPosition.FarLeft,
ShortLinesPosition.MiddleLeft,
ShortLinesPosition.FarRight,
ShortLinesPosition.MiddleRight,
][CirclePosition.enumValueToNumber(this.enumValue)]
: [
ShortLinesPosition.MiddleLeft,
ShortLinesPosition.FarLeft,
ShortLinesPosition.MiddleRight,
ShortLinesPosition.FarRight,
][CirclePosition.enumValueToNumber(this.enumValue)];
}
public swapDiagonal() : CirclePosition {
return this.swapAcross().swapUpAndDown();
}
@ -236,16 +220,6 @@ export class ShortLinesPosition {
][ShortLinesPosition.enumValueToNumber(this.enumValue)];
}
public shift(dir: Hand, facing: Facing.Up | Facing.Down): ShortLinesPosition {
const shift = (dir === Hand.Left) === (facing === Facing.Down) ? -1 : +1;
const newNum = ShortLinesPosition.enumValueToNumber(this.enumValue) + shift;
if (newNum < 0 || newNum > 3) {
throw new Error("Invalid shift: " + this + " facing " + facing + " to " + dir + ".");
}
return ShortLinesPosition.get(ShortLinesPosition.numberToEnumValue(newNum));
}
public isMiddle() : boolean {
return this.enumValue === ShortLinesPositionEnum.MiddleRight || this.enumValue === ShortLinesPositionEnum.MiddleLeft;
}

View File

@ -3,7 +3,7 @@ import * as common from "./danceCommon.js";
import { DanceRole, DancerIdentity, Rotation } from "./danceCommon.js";
import { BalanceWeight, CirclePosition, CircleSide, CircleSideOrCenter, DancerDistance, Facing, HandConnection, HandTo, LongLines, PositionKind, SemanticPosition, ShortLinesPosition, StarGrip, handsInCircle } from "./interpreterCommon.js";
import { Move } from "./libfigureMapper.js";
import { DancerSetPosition, Hand, Offset, OffsetPlus, OffsetRotate, OffsetTimes, OffsetTranspose, dancerHeight, dancerHeightOffset, dancerWidth, lineDistance, offsetZero, setDistance, setHeight, setSpacing, setWidth } from "./rendererConstants.js";
import { DancerSetPosition, Hand, Offset, OffsetPlus, OffsetRotate, OffsetTimes, OffsetTranspose, dancerHeightOffset, dancerWidth, lineDistance, offsetZero, setDistance, setHeight, setSpacing, setWidth } from "./rendererConstants.js";
export enum SemanticAnimationKind {
@ -374,15 +374,12 @@ function SemanticToSetPosition(semantic: SemanticPosition): DancerSetPosition {
};
case PositionKind.ShortLines:
let yOffset = 0;
switch (semantic.facing) {
case Facing.Up:
rotation = Rotation.Up;
yOffset = +dancerHeight;
break;
case Facing.Down:
rotation = Rotation.Down;
yOffset = -dancerHeight;
break;
case Facing.Left:
rotation = Rotation.Left;
@ -396,16 +393,16 @@ function SemanticToSetPosition(semantic: SemanticPosition): DancerSetPosition {
switch (semantic.which) {
case ShortLinesPosition.FarLeft:
position = { x: -1.5, y: yOffset };
position = { x: -1.5, y: 0 };
break;
case ShortLinesPosition.MiddleLeft:
position = { x: -0.5, y: yOffset };
position = { x: -0.5, y: 0 };
break;
case ShortLinesPosition.MiddleRight:
position = { x: +0.5, y: yOffset };
position = { x: +0.5, y: 0 };
break;
case ShortLinesPosition.FarRight:
position = { x: +1.5, y: yOffset };
position = { x: +1.5, y: 0 };
break;
default:
throw "Invalid circle position: " + semantic.which;
@ -448,14 +445,12 @@ function SemanticToSetPosition(semantic: SemanticPosition): DancerSetPosition {
// TODO Hands. Might need more info? Or need context of nearby dancer SemanticPositions?
if (!connection) return undefined;
const balanceYOffset = (semantic.facing === Facing.Up ? yOffset : -yOffset)
+ (semantic.balance === BalanceWeight.Forward ? -shortWavesBalanceAmount : semantic.balance === BalanceWeight.Backward ? shortWavesBalanceAmount : 0);
const balanceXOffset = semantic.balance === BalanceWeight.Left ? -balanceAmount : semantic.balance === BalanceWeight.Right ? balanceAmount : 0;
const balanceYOffset = semantic.balance === BalanceWeight.Forward ? -shortWavesBalanceAmount : semantic.balance === BalanceWeight.Backward ? shortWavesBalanceAmount : 0;
switch (connection.to) {
case HandTo.DancerLeft:
return { x: -0.5 + balanceXOffset, y: balanceYOffset };
return { x: -0.5, y: balanceYOffset };
case HandTo.DancerRight:
return { x: +0.5 + balanceXOffset, y: balanceYOffset };
return { x: +0.5, y: balanceYOffset };
case HandTo.DancerForward:
if (hand === connection.hand) {
return { x: 0, y: +0.5 };