> ## Content Index
> Fetch the complete content index at: https://evil-penguin.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Frame Transitions
- URL: https://evil-penguin.com/frame-transitions/
- Published: 2024-11-08T13:42:37.000Z
- Updated: 2026-11-16T23:02:11.000Z
- Description: Have you ever wondered how games transition from one frame to another?
- Author: evilpenguin
- Tags: C, MLX

When you have two scenes and you want to pass from one to another, what is the best way to do it?  
  
For example, imagine that you have a menu, and you want to transition to the settings screen.  
You can do something sweet and interpolate both images to create a smooth transition.  
This can be implemented for anything you want, for example, if you die in the game, you can transition from the current scene to a dead screen menu. 

## Linear Interpolation \`lerp()\`

The answer is "Linear Interpolation"  
This allows us to interpolate two vectors to generate a new vector in the same -inf+ vector span of the two given vectors.  
  
So we can considerate each pixel of the frame as a vector (Color RGBA) in this case you can use a Vector3 or Vector4 depending if you want to considerate the opacity.  
  
Then all you need to do is to interpolate each corresponding vector/color from each frame. This can also be done with two different positions, to translate from one position to another by interpolating between the start and end.  
  
In this case I implemented a super simple example using mlx.  
  
See the Examples bellow.  
  
Note:  
There are two versions on the "Python/Ruby" transition, one does not consider the opacity (Vector3) and the other does consider the opacity (Vector4)  
  
Here is the example if you want to check the code out (it's very small): [https://github.com/pulgamecanica/42Course/tree/main/42Documentation/transitions](https://github.com/pulgamecanica/42Course/tree/main/42Documentation/transitions?ref=evil-penguin.com)

![](https://evil-penguin.com/content/images/2026/11/ScreencastFrom2024-11-0813-58-15-ezgif.com-video-to-gif-converter.gif)

![](https://evil-penguin.com/content/images/2026/11/ScreencastFrom2024-11-0814-20-43-ezgif.com-video-to-gif-converter.gif)

![](https://evil-penguin.com/content/images/2026/11/ScreencastFrom2024-11-0814-21-25-ezgif.com-video-to-gif-converter.gif)