dog

Back to All Results

Motion Vectorization

Input video: dog

Output SVG motion program code

Output SVG motion program

Motion Program Transformation

Retiming

Retiming to music beats

Input SVG motion program

MPTransformer(P, args):
  // OBJECT SELECTOR: Query for all shapes with the "all" propType.
  // No matchCriteria is needed, hence an empty array [].
  selObjs = objSelector(P, propQuery, "all", [], [0, P.endFrm])

  // Make two copies of the objects to change their appearances later.
  catObjs = copy(selObjs)
  eleObjs = copy(selObjs)

  // OBJECT SELECTOR: Query for static shapes in catObjs 
  // and elephantObjs by checking if a shape has 0 velocity.
  catStaticObjs = objSelector(P, propQuery, "velocity", [0], [0,P.endFrm])
  eleStaticObjs = objSelector(P, propQuery, "velocity", [0], [0,P.endFrm])

  // OBJECT TRANSFORMER: Change the appearances of static objects
  // to make them look like a cat and an elephant respectively.
  changeAppearanceObjTransformer(catStaticObjs, ["catEarL.png", 
                              "catEarR.png", "catMouthWhiskers.png"] 
                              [0, P.endFrm])
  changeAppearanceObjTransformer(eleStaticObjs, ["eleEarL.png", 
                              "eleEarR.png", "eleTrunk.png"] 
                              [0, P.endFrm])

  // Retime the cat and elephant objects to go after the original objects
  // P.endFrm is automatically updated by retime(), so we need to save
  // the original value first.
  currEndFrm = P.endFrm
  for each obj in catObjs: 
    retime(obj, [0, currEndFrm], [currEndFrm, currEndFrm * 2], f(t)=t)

  for each obj in eleObjs: 
    retime(obj, [0, currEndFrm], [currEndFrm * 2, currEndFrm * 3], f(t)=t)

  // OBJECT TRANSFORMER: Retime cyclic motions in the entire video to 
  // match with the music beats by specifying the event type as 
  // "motionCycleFrames". Note that P.endFrm has been updated in the 
  // previous retime operations
  retimeToBeatsObjTransformer(selObjs, "BeatOfTheIsland.wav", 
                              "motionCycleFrames", [0, P.endFrm])

Motion program transformer code. Here we first change the appearance of the dog to resemble a cat and an elephant with changeAppearanceObjTransformer. Then we retime the cyclic motions of the seesaw to match the music beats with retimeToBeatsObjTransformer.

Output SVG motion program

Appearance Adjustment

Simple appearance adjustment

Input SVG motion program

MPTransformer(P, args):
  // OBJECT SELECTOR: Query for all shapes with the "all" propType.
  // No matchCriteria is needed, hence an empty array [].
  selObjs = objSelector(P, propQuery, "all", [], [0, P.endFrm])

  // Make two copies of the objects to change their appearances later.
  catObjs = copy(selObjs)
  eleObjs = copy(selObjs)

  // OBJECT TRANSFORMER: Query for static shapes in catObjs 
  // and elephantObjs by checking if a shape has 0 velocity.
  catStaticObjs = objSelector(P, propQuery, "velocity", [0], [0,P.endFrm])
  eleStaticObjs = objSelector(P, propQuery, "velocity", [0], [0,P.endFrm])

  // OBJECT TRANSFORMER: Change the appearances of static objects
  // to make them look like a cat and an elephant respectively.
  changeAppearanceObjTransformer(catStaticObjs, ["catEarL.png", 
                              "catEarR.png", "catMouthWhiskers.png"] 
                              [0, P.endFrm])
  changeAppearanceObjTransformer(eleStaticObjs, ["eleEarL.png", 
                              "eleEarR.png", "eleTrunk.png"] 
                              [0, P.endFrm])

  // Retime the cat and elephant objects to go after the original objects
  // P.endFrm is automatically updated by retime(), so we need to save
  // the original value first.
  currEndFrm = P.endFrm
  for each obj in catObjs: 
    retime(obj, [0, currEndFrm], [currEndFrm, currEndFrm * 2], f(t)=t)

  for each obj in eleObjs: 
    retime(obj, [0, currEndFrm], [currEndFrm * 2, currEndFrm * 3], f(t)=t)
  

Motion program transformer code. Here we change the appearance of the dog to resemble a cat and an elephant with changeAppearanceObjTransformer.

Output SVG motion program