Compare commits

..

No commits in common. "ad14e4e51f031a3aeced300aeca41a0f1e380813" and "61badb64048cfe2a547954c2b322b390f5138b1e" have entirely different histories.

4 changed files with 39 additions and 104 deletions

View File

@ -238,21 +238,7 @@ export class TransitionAnimationSegment extends AnimationSegment {
}
override drawDebug(ctx: CanvasRenderingContext2D, progress: number) {
// TODO better way to display transition?
if (progress < this.startTransitionProgress) {
ctx.beginPath();
ctx.moveTo(this.startPosition.position.x, this.startPosition.position.y);
const transitionStart = this.actualAnimation.interpolateOffset(this.startTransitionProgress);
ctx.lineTo(transitionStart.x, transitionStart.y);
ctx.stroke();
} else if (progress > 1 - this.endTransitionProgress) {
ctx.beginPath();
const transitionEnd = this.actualAnimation.interpolateOffset(this.endTransitionProgress);
ctx.moveTo(transitionEnd.x, transitionEnd.y);
ctx.lineTo(this.endPosition.position.x, this.endPosition.position.y);
ctx.stroke();
}
// TODO display transition somehow?
this.actualAnimation.drawDebug(ctx, progress);
}
}

View File

@ -594,7 +594,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
});
case "swing":
return handlePairedMove(move.parameters.who, ({ id, startPos, around, withId, withPos }) => {
return handlePairedMove(move.parameters.who, ({ id, startPos, around, withId }) => {
// TODO swing can start from non-circle positions.
// TODO swing end is only in notes / looking at next move.
@ -602,7 +602,6 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
// TODO more structured way to do this than enumerating next moves here?
// maybe instead of nextMove an optional endPosition for fixing up positions?
// ... but then every move would have to handle that...
const afterTake = startPos.longLines === LongLines.Near || withPos.longLines === LongLines.Near;
const toShortLines = nextMove.move === "down the hall" || nextMove.move === "up the hall";
const endFacingAcross = (around === CircleSide.Left || around === CircleSide.Right) && !toShortLines;
@ -610,10 +609,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
const startPosition: SemanticPosition = {
...startPos,
facing: around === CircleSide.Left || CircleSide.Right
? (startWhich instanceof CirclePosition
? afterTake
? startPos.longLines === LongLines.Near ? startWhich.facingOut() : startWhich.facingAcross()
: (startWhich.topBottomSide() === CircleSide.Bottom ? Facing.Up : Facing.Down)
? (startWhich instanceof CirclePosition ? (startWhich.topBottomSide() === CircleSide.Bottom ? Facing.Up : Facing.Down)
: startWhich.facingSide())
: (startWhich.isLeft() ? Facing.Right : Facing.Left),
};
@ -695,7 +691,6 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
around,
endFacing: startWhich.leftRightSide() === CircleSide.Left ? Facing.Right : Facing.Left,
swingRole,
afterTake,
},
};
@ -771,9 +766,8 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
return handleCirclePairedMove(move.parameters.who, ({ startPos }) => {
const handTo = startPos.which.isOnLeftLookingAcross() ? HandTo.DancerRight : HandTo.DancerLeft;
const startingPos: SemanticPosition = {
const startingPos = {
...startPos,
facing: startPos.which.facingAcross(),
dancerDistance: DancerDistance.Compact,
hands: new Map<Hand, HandConnection>([
[Hand.Left, { hand: Hand.Left, to: handTo }],
@ -880,9 +874,9 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
endPosition = withPos;
} else if (intoWave) {
if (startPos.kind === PositionKind.ShortLines) {
if (around === CircleSide.Left || around === CircleSide.Right) {
// Fix startPos if necessary. Needed because pass through always swaps but sometimes shouldn't.
if ((startPos.facing === Facing.Up || startPos.facing === Facing.Down) &&
if ((around === CircleSide.Left || around === CircleSide.Right) &&
(startPos.facing === Facing.Up || startPos.facing === Facing.Down) &&
((byHandOrShoulder === Hand.Right)
!== (startPos.facing === Facing.Up)
!== (startPos.which === ShortLinesPosition.FarLeft || startPos.which === ShortLinesPosition.MiddleRight))) {
@ -907,27 +901,10 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
setOffset: startingPos.setOffset,
lineOffset: startingPos.lineOffset,
}
} else {
throw new Error("Allemande from short lines to line line in middle unsupported.");
}
} else {
if (around === "Center") {
const startCenter = startPos.longLines === LongLines.Center;
const endWhich = startPos.which.circleRight(intoWavePositions);
endPosition = {
kind: PositionKind.Circle,
which: endWhich,
facing: startPos.which.facingOut(),
longLines: startCenter ? undefined : LongLines.Center,
setOffset: startPos.setOffset,
lineOffset: startPos.lineOffset,
}
} else {
throw new Error("Allemande from circle to short lines is unsupported.");
}
}
}
return combine([
{
@ -1469,7 +1446,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
{
beats: backwardBeats,
endPosition: startPosition,
movementPattern: { kind: SemanticAnimationKind.Linear, minRotation: 0 },
movementPattern: { kind: SemanticAnimationKind.Linear },
},
], startPosition);
} else {

View File

@ -345,9 +345,6 @@ export enum LongLines {
// Only a little offset (has walked almost all the way from the other side after a give and take).
Near = "Near",
// Actually in center. May be slightly offset for wavy lines.
Center = "Center",
}
export type SemanticPosition = {
kind: PositionKind.Circle,

View File

@ -88,9 +88,6 @@ export type SemanticAnimation = {
// Swings are asymmetric. This is usually but not always the dancer's role.
swingRole: common.DanceRole,
// After a take need to fixup the position.
afterTake: boolean,
} | {
kind: SemanticAnimationKind.TwirlSwap,
@ -273,8 +270,6 @@ function SemanticToSetPosition(semantic: SemanticPosition): DancerSetPosition {
throw "Invalid circle position: " + semantic.which;
}
switch(semantic.longLines) {
case LongLines.Center:
position.x *= 0.1;
case LongLines.Forward:
position.x *= 0.3;
case LongLines.Near:
@ -590,7 +585,6 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
])
}),
flags: {
rotation: true,
hands: true,
handsDuring: circleHands,
},
@ -675,26 +669,15 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
const baseSwingStart = {
...move.startPosition,
dancerDistance: move.movementPattern.afterTake ? undefined : dancerDistance,
dancerDistance,
balance: undefined,
longLines: undefined,
}
const swingStartUnadjusted = SemanticToSetPosition(move.startPosition.longLines === LongLines.Near ? {
const swingStart = SemanticToSetPosition(move.startPosition.longLines === LongLines.Near ? {
...baseSwingStart,
kind: PositionKind.Circle,
which: move.startPosition.which.swapUpAndDown(),
} : baseSwingStart);
const swingStart = move.movementPattern.afterTake
? {
...swingStartUnadjusted, position: {
x: swingStartUnadjusted.position.x
+ ((move.startPosition.longLines === LongLines.Near) === (move.startPosition.which.isLeft())
? +0.5
: -0.5),
y: rotateSwingCenter.y,
}
}
: swingStartUnadjusted;
const beforeUnfold = SemanticToSetPosition({
...move.endPosition,
dancerDistance,
@ -713,16 +696,15 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
const turns = Math.ceil(Math.abs(move.movementPattern.minAmount / 360));
const swingMinRotation = (minTurns - turns) * (move.movementPattern.minAmount < 0 ? -360 : 360) + move.movementPattern.minAmount;
const slideAmount = move.movementPattern.afterTake ? { x: 0, y: rotateSwingCenter.y - startSetPosition.position.y } : undefined;
const swingAnimation = new animation.TransitionAnimationSegment({
return [
new animation.TransitionAnimationSegment({
actualAnimation: new animation.RotationAnimationSegment({
beats: swingBeats,
startPosition: slideAmount ? { ...swingStart, position: OffsetPlus(swingStart.position, OffsetTimes(slideAmount, -1)) } : swingStart,
endPosition: slideAmount ? { ...beforeUnfold, position: OffsetPlus(beforeUnfold.position, OffsetTimes(slideAmount, -1)) } : beforeUnfold,
startPosition: swingStart,
endPosition: beforeUnfold,
rotation: swingMinRotation,
around: {
center: slideAmount ? OffsetPlus(rotateSwingCenter, OffsetTimes(slideAmount, -1)) : rotateSwingCenter,
center: rotateSwingCenter,
width: 1,
height: 1,
},
@ -740,14 +722,7 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
},
startTransitionBeats: 1,
endTransitionBeats: 0,
});
return [
slideAmount ? new animation.SlideAnimationSegment(
swingAnimation.beats,
[swingAnimation],
slideAmount,
) : swingAnimation,
}),
new animation.LinearAnimationSegment({
beats: 1,
startPosition: beforeUnfold,