Input video: sydney
Output SVG motion program code
Output SVG motion program
SVG motion program code (uncorrected tracking)
SVG motion program (uncorrected tracking)
Input SVG motion program
MPTransformer(P, args):
// Change the background.
setBgImg(P, args.background)
// OBJECT SELECTOR: Select all objects in the top third of the video.
function in_top_third(y):
if y > P.height / 3:
return False
return True
topObjs = objSelector(P, propQuery, "positionY", in_top_third, [0, P.endFrm])
// Sort all objects by x position at the very end. We will change the leftmost
// object to the new translated location and the rightmost object to the new
// translation for "explore."
function xComparator(obj):
return propQuery(obj, "positionX", [P.endFrm - 1, P.endFrm])[0]
topObjs = sorted(topObjs, key=xComparator)
changeObjs = [topObjs[0], topObjs[-1]]
// OBJECT TRANSFORMER: Change to new language and shift them so that they end
// up in the bounds of the screen.
changeAppearanceObjTransformer(changeObjs, args.topText, [0, P.endFrm])
function xShift(t, [x, amt]):
return x[t] + amt
adjLocalObjMotion(changeObjs[0], setX, [changeObjs[0].startFrm, changeObjs[0].endFrm], amt=args.bottomTextShift)
adjLocalObjMotion(changeObjs[-1], setX, [changeObjs[-1].startFrm, changeObjs[-1].endFrm], amt=-args.bottomTextShift)
// Remove all the other objects.
removeObjs(topObjs[1:-1])
// OBJECT SELECTOR: Select all objects in the bottom third of the video.
function in_bottom_third(y):
if y < 2 * P.height / 3:
return False
return True
bottomObjs = objSelector(P, propQuery, "positionY", in_bottom_third, [0, P.endFrm])
// Sort all objects by x position at the very end. We will change one object to
// the first translated phrase and another object to the second translated phase.
bottomObjs = sorted(bottomObjs, key=xComparator)
// OBJECT TRANSFORMER: Change to new language and shift them inwards.
changeAppearance(bottomObjs[len(bottomObjs) // 2], args.bottomText)
// Remove all the other objects.
removeObjs(bottomObjs[:len(bottomObjs) // 2])
removeObjs(bottomObjs[len(bottomObjs) // 2 + 1:])
// OBJECT SELECTOR: Select the plane by querying for objects which pass through the middle third
// of the video.
function in_bottom_third(vals):
if y > 2 * P.height / 3 or y < P.height / 3:
return False
return True
planeObjs = objSelector(P, propQuery, "positionY", in_middle_third, [0, P.endFrm])
// OBJECT TRANSFORMER: Change the plane to a cruise ship and make it travel slowly in a straight line.
changeAppearanceObjTransformer(planeObjs, args.boat)
function constantY(t, [y, amt]):
return y[0]
adjGlobalObjTransformer(planeObjs, constantY, [changeObjs[0].startFrm, changeObjs[0].endFrm])
function scaleXPosition(t, [x]):
return x[t // 2]
adjGlobalObjTransformer(planeObjs, scaleXPosition, m_duration, [planeObjs[0].startFrm, planeObjs[0].endFrm])
function quadEaseInOut(t):
easedT = 0
if t < 0.5:
return t^2
else:
1 - t^2
slowInOutObjTransformer(planeObjs, quadEaseInOut, [planeObjs[0].startFrm, planeObjs[1].startFrm])
Motion program transformer code. Here we change the appearances of the background and text to advertise a cruise to Alaska for Seattle residents. We use a adjGlobalObjTransformer to make the motion of the cruise more ship-like.
Output SVG motion program
Input SVG motion program
MPTransformer(P, args):
// Change the background.
changeAppearance(P, args.background)
// OBJECT SELECTOR: Select all objects in the top third of the video.
// Sort them by y-position at the very end. We will only change two objects.
function in_top_third(vals):
if y > m_frame_height / 3:
return False
return True
topObjs = objSelector(P, propQuery, "positionY", in_top_third, [0, P.endFrm])
function yComparator(obj):
return propQuery(obj, "positionY", [P.endFrm - 1, P.endFrm])[0]
bottomObjs = sorted(bottomObjs, key=yComparator)
changeObjs = [topObjs[0], topObjs[-1]]
// OBJECT TRANSFORMER: Change to new language and shift them so that they end
// up in the bounds of the screen.
changeAppearanceObjTransformer(changeObjs, arg.topText, [0, P.endFrm])
function xShift(t, [x, amt]):
return x[t] + amt
adjGlobalMotion(changeObjs[0], xShift, [changeObjs[0].startFrm, changeObjs[0].endFrm], args.shiftDiscover)
adjGlobalMotion(changeObjs[1], xShift, [changeObjs[1].startFrm, changeObjs[1].endFrm], args.shiftSydney)
// Remove all the other objects.
removeObjs(topObjs[1:-1])
// OBJECT SELECTOR: Select all objects in the bottom third of the video.
function in_bottom_third(y):
if y < 2 * P.height / 3:
return False
return True
bottomObjs = objSelector(P, "positionY", in_bottom_third, [0, P.endFrm])
// Sort all objects by x position at the very end. We will change on object to
// The first translated phrase and another object to the second translated phase.
function xComparator(obj):
return propQuery(obj, "positionX", [P.endFrm - 1, P.endFrm])[0]
bottomObjs = sorted(bottomObjs, key=xComparator)
copyObjs = copy(bottomObjs[0])
changeObjs = [bottomObjs[0], copyObjs[0]]
// OBJECT TRANSFORMER: Change to new language and shift them inwards.
changeAppearanceObjTransformer(changeObjs, args.bottomText, [0, P.endFrm])
function setX(t, [x, amt]):
return amt
adjLocalMotion(changeObjs[0], setX, [changeObjs[0].startFrm, changeObjs[0].endFrm], args.bottomTextShift)
adjLocalMotion(changeObjs[1], setX, [changeObjs[1].startFrm, changeObjs[1].endFrm], -args.bottomTextShift)
// Delay the second phrase by a little bit.
linearRetimeObjTransformer(changeObjs[1], 5, [0, 1])
// Remove all the other objects.
removeObjs(bottomObjs[1:])
Motion program transformer code. We use appearance changes to translate the advertisement for Chinese tourists interested in traveling to Spain.
Output SVG motion program