# Overlap two images and give movement and the result record it in an animated gif

I need to put the circular image 1 in the image with the hole 2 (and cover the gap) the idea is to create an animated gif that shows the image 1 turning to the right and image 2 to the left in a size that can be projected (regular movement). It will be possible to do with mathematica. Beforehand thank you very much.

EDIT

Something like this, but with 2 images, one turns to one side in the center and the other rotates in the opposite direction

How to rotate a complete graph without image rescaling while rotating

image 1

image 2

Using the two images

{i1, i2}  = {Import["https://i.stack.imgur.com/vmG0o.png"],
Import["https://i.stack.imgur.com/bOkO8.png"]}


create two polygons Textured with the two images:

{g1, g2} = {Texture@#, Polygon[p = Table[#2 {Sin @ t, Cos @ t}, {t, 0, 2 Pi, Pi/32}],
VertexTextureCoordinates -> Transpose[Rescale /@ Transpose@p]]}&@@@{{i1, 1}, {i2, 1.5}};


and use GeometricTransformation + RotationTransform to rotate the two polygons in opposite directions controlling the rotation angle with

Clock[{a, b, c}, d, e]


whose value cycles from a to b in steps of c once every d seconds and stops after e cycles. Wrapping all with Dynamic

Dynamic @ With[{t = Clock[{0, 2 Pi, Pi/32}, 3, 1]},
Graphics[GeometricTransformation[#, RotationTransform[#2 t]] & @@@ {{g2, -1}, {g1, 1}}]]


gives the animation at the top.

Alternatively, you can generate a table of frames and ListAnimate them or Export them as a GIF file:

frames = Table[Graphics[GeometricTransformation[#,
RotationTransform[#2 t]] & @@@ {{g2, -1}, {g1, 1}}], {t, 0, 2 Pi, Pi /64}];
ListAnimate[frames]


Export["file1.gif", frames]

• ,thank you very much, you would be so kind to explain to me a bit the code, and how to pass the animation to an animated gif. It's just what I was using. Jul 5, 2018 at 1:30
• is there any way for the movement to be more fluid Jul 5, 2018 at 3:00
• @Walter, please see the updated version.
– kglr
Jul 5, 2018 at 4:07
• Thank you very much, I am perfect Jul 6, 2018 at 11:22