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) { override drawDebug(ctx: CanvasRenderingContext2D, progress: number) {
// TODO better way to display transition? // TODO display transition somehow?
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();
}
this.actualAnimation.drawDebug(ctx, progress); this.actualAnimation.drawDebug(ctx, progress);
} }
} }

View File

@ -594,7 +594,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
}); });
case "swing": 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 can start from non-circle positions.
// TODO swing end is only in notes / looking at next move. // 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? // TODO more structured way to do this than enumerating next moves here?
// maybe instead of nextMove an optional endPosition for fixing up positions? // maybe instead of nextMove an optional endPosition for fixing up positions?
// ... but then every move would have to handle that... // ... 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 toShortLines = nextMove.move === "down the hall" || nextMove.move === "up the hall";
const endFacingAcross = (around === CircleSide.Left || around === CircleSide.Right) && !toShortLines; const endFacingAcross = (around === CircleSide.Left || around === CircleSide.Right) && !toShortLines;
@ -610,10 +609,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
const startPosition: SemanticPosition = { const startPosition: SemanticPosition = {
...startPos, ...startPos,
facing: around === CircleSide.Left || CircleSide.Right facing: around === CircleSide.Left || CircleSide.Right
? (startWhich instanceof CirclePosition ? (startWhich instanceof CirclePosition ? (startWhich.topBottomSide() === CircleSide.Bottom ? Facing.Up : Facing.Down)
? afterTake
? startPos.longLines === LongLines.Near ? startWhich.facingOut() : startWhich.facingAcross()
: (startWhich.topBottomSide() === CircleSide.Bottom ? Facing.Up : Facing.Down)
: startWhich.facingSide()) : startWhich.facingSide())
: (startWhich.isLeft() ? Facing.Right : Facing.Left), : (startWhich.isLeft() ? Facing.Right : Facing.Left),
}; };
@ -695,7 +691,6 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
around, around,
endFacing: startWhich.leftRightSide() === CircleSide.Left ? Facing.Right : Facing.Left, endFacing: startWhich.leftRightSide() === CircleSide.Left ? Facing.Right : Facing.Left,
swingRole, swingRole,
afterTake,
}, },
}; };
@ -771,9 +766,8 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
return handleCirclePairedMove(move.parameters.who, ({ startPos }) => { return handleCirclePairedMove(move.parameters.who, ({ startPos }) => {
const handTo = startPos.which.isOnLeftLookingAcross() ? HandTo.DancerRight : HandTo.DancerLeft; const handTo = startPos.which.isOnLeftLookingAcross() ? HandTo.DancerRight : HandTo.DancerLeft;
const startingPos: SemanticPosition = { const startingPos = {
...startPos, ...startPos,
facing: startPos.which.facingAcross(),
dancerDistance: DancerDistance.Compact, dancerDistance: DancerDistance.Compact,
hands: new Map<Hand, HandConnection>([ hands: new Map<Hand, HandConnection>([
[Hand.Left, { hand: Hand.Left, to: handTo }], [Hand.Left, { hand: Hand.Left, to: handTo }],
@ -880,9 +874,9 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
endPosition = withPos; endPosition = withPos;
} else if (intoWave) { } else if (intoWave) {
if (startPos.kind === PositionKind.ShortLines) { 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. // 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) ((byHandOrShoulder === Hand.Right)
!== (startPos.facing === Facing.Up) !== (startPos.facing === Facing.Up)
!== (startPos.which === ShortLinesPosition.FarLeft || startPos.which === ShortLinesPosition.MiddleRight))) { !== (startPos.which === ShortLinesPosition.FarLeft || startPos.which === ShortLinesPosition.MiddleRight))) {
@ -907,27 +901,10 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
setOffset: startingPos.setOffset, setOffset: startingPos.setOffset,
lineOffset: startingPos.lineOffset, 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 { } else {
throw new Error("Allemande from circle to short lines is unsupported."); throw new Error("Allemande from circle to short lines is unsupported.");
} }
} }
}
return combine([ return combine([
{ {
@ -1469,7 +1446,7 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
{ {
beats: backwardBeats, beats: backwardBeats,
endPosition: startPosition, endPosition: startPosition,
movementPattern: { kind: SemanticAnimationKind.Linear, minRotation: 0 }, movementPattern: { kind: SemanticAnimationKind.Linear },
}, },
], startPosition); ], startPosition);
} else { } 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). // Only a little offset (has walked almost all the way from the other side after a give and take).
Near = "Near", Near = "Near",
// Actually in center. May be slightly offset for wavy lines.
Center = "Center",
} }
export type SemanticPosition = { export type SemanticPosition = {
kind: PositionKind.Circle, 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. // Swings are asymmetric. This is usually but not always the dancer's role.
swingRole: common.DanceRole, swingRole: common.DanceRole,
// After a take need to fixup the position.
afterTake: boolean,
} | { } | {
kind: SemanticAnimationKind.TwirlSwap, kind: SemanticAnimationKind.TwirlSwap,
@ -273,8 +270,6 @@ function SemanticToSetPosition(semantic: SemanticPosition): DancerSetPosition {
throw "Invalid circle position: " + semantic.which; throw "Invalid circle position: " + semantic.which;
} }
switch(semantic.longLines) { switch(semantic.longLines) {
case LongLines.Center:
position.x *= 0.1;
case LongLines.Forward: case LongLines.Forward:
position.x *= 0.3; position.x *= 0.3;
case LongLines.Near: case LongLines.Near:
@ -590,7 +585,6 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
]) ])
}), }),
flags: { flags: {
rotation: true,
hands: true, hands: true,
handsDuring: circleHands, handsDuring: circleHands,
}, },
@ -675,26 +669,15 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
const baseSwingStart = { const baseSwingStart = {
...move.startPosition, ...move.startPosition,
dancerDistance: move.movementPattern.afterTake ? undefined : dancerDistance, dancerDistance,
balance: undefined, balance: undefined,
longLines: undefined, longLines: undefined,
} }
const swingStartUnadjusted = SemanticToSetPosition(move.startPosition.longLines === LongLines.Near ? { const swingStart = SemanticToSetPosition(move.startPosition.longLines === LongLines.Near ? {
...baseSwingStart, ...baseSwingStart,
kind: PositionKind.Circle, kind: PositionKind.Circle,
which: move.startPosition.which.swapUpAndDown(), which: move.startPosition.which.swapUpAndDown(),
} : baseSwingStart); } : 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({ const beforeUnfold = SemanticToSetPosition({
...move.endPosition, ...move.endPosition,
dancerDistance, dancerDistance,
@ -713,16 +696,15 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
const turns = Math.ceil(Math.abs(move.movementPattern.minAmount / 360)); const turns = Math.ceil(Math.abs(move.movementPattern.minAmount / 360));
const swingMinRotation = (minTurns - turns) * (move.movementPattern.minAmount < 0 ? -360 : 360) + move.movementPattern.minAmount; 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; return [
new animation.TransitionAnimationSegment({
const swingAnimation = new animation.TransitionAnimationSegment({
actualAnimation: new animation.RotationAnimationSegment({ actualAnimation: new animation.RotationAnimationSegment({
beats: swingBeats, beats: swingBeats,
startPosition: slideAmount ? { ...swingStart, position: OffsetPlus(swingStart.position, OffsetTimes(slideAmount, -1)) } : swingStart, startPosition: swingStart,
endPosition: slideAmount ? { ...beforeUnfold, position: OffsetPlus(beforeUnfold.position, OffsetTimes(slideAmount, -1)) } : beforeUnfold, endPosition: beforeUnfold,
rotation: swingMinRotation, rotation: swingMinRotation,
around: { around: {
center: slideAmount ? OffsetPlus(rotateSwingCenter, OffsetTimes(slideAmount, -1)) : rotateSwingCenter, center: rotateSwingCenter,
width: 1, width: 1,
height: 1, height: 1,
}, },
@ -740,14 +722,7 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
}, },
startTransitionBeats: 1, startTransitionBeats: 1,
endTransitionBeats: 0, endTransitionBeats: 0,
}); }),
return [
slideAmount ? new animation.SlideAnimationSegment(
swingAnimation.beats,
[swingAnimation],
slideAmount,
) : swingAnimation,
new animation.LinearAnimationSegment({ new animation.LinearAnimationSegment({
beats: 1, beats: 1,
startPosition: beforeUnfold, startPosition: beforeUnfold,