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.


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

enter image description here

image 2 enter image description here


1 Answer 1


enter image description here

Using the two images

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

enter image description here enter image description here

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}];

enter image description here

Export["file1.gif", frames]
  • $\begingroup$ ,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. $\endgroup$
    – Walter
    Jul 5, 2018 at 1:30
  • $\begingroup$ is there any way for the movement to be more fluid $\endgroup$
    – Walter
    Jul 5, 2018 at 3:00
  • $\begingroup$ @Walter, please see the updated version. $\endgroup$
    – kglr
    Jul 5, 2018 at 4:07
  • $\begingroup$ Thank you very much, I am perfect $\endgroup$
    – Walter
    Jul 6, 2018 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.