The task:

Animate the rotation of two connected mechanical gears on a canvas.

It seems that it just sounds, but due to poor knowledge of the language, I can’t figure out how to approach the task and what to use. Can you tell me how to build a gear without using additional libraries?

  • What exactly is causing you difficulty? Can you specify a gear in the form of a set of segments? Can you draw a gear on canvas? And turn her? And draw two and rotate them together? - Kromster
  • As a set of segments probably not, it must also be painted over completely. And the more you can rotate 1 obkt, and how to rotate their set at the same time? Is it for each segment to write a rotation function? It is unlikely that this is the optimal solution in reality - Alexey
  • general structure: 1- drew a static gear (if it is not clear how, ask a separate question). Give a picture of what you want to get 2- learned to rotate (simple matrix multiplication - if it's not clear how to make one turn, ask a separate question) 3- learn a simple cycle in tkinter to start 4- one gear to start the rotation automatically 5- add next to the second - jfs
  • Well, I'll try to figure it out. Can you just tell if the gear should be created as a collection of elements, or is there some function to create a complex element? If created as a collection of elements, do they need to assign a common tag to multiply by a matrix? - Alexey
  • where did you get the condition: "without additional libraries"? In tkinter, you will have to manually implement things (such as rotation) that can be embedded in other libraries (Qt, Kivy, pygame) ¶ Try it in the simplest way: draw a static picture at a given center (x, y) and angle (alpha) ( you can draw any elements). Then the rotation is reduced to changing the angle of the object and calling the redrawing method (emptying the canvas on each frame) ¶ In a more general case, you can implement a Transform object that can do various transformations over the list of coordinates (then draw as a polygon). - jfs

0