im-ushan-ikshana / game_cpp_sfml_linked

The "Rainbow Transition with SFML" code is a C++ program that utilizes the Simple and Fast Multimedia Library (SFML) to create an engaging visual effect.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐ŸŒˆ Rainbow Transition with SFML(SFML LINKED) ๐ŸŽฎ

This C++ code, using the Simple and Fast Multimedia Library (SFML), creates a mesmerizing ๐ŸŒˆ rainbow transition effect on a rectangle ๐ŸŸฉ that covers the entire window. The rectangle smoothly changes colors over time, creating a rainbow-like animation.

๐Ÿ“ฆ Dependencies

Before running the code, make sure you have SFML correctly set up in your development environment.

๐Ÿ’ป Code Description

This code provides an engaging example of utilizing SFML for graphical applications. It demonstrates how to create a visually stimulating rainbow transition effect using a combination of time-based color calculations, HSV to RGB conversion, and simple rendering techniques. The result is an interactive and aesthetically pleasing animation that smoothly transitions through a spectrum of colors, offering an enjoyable visual experience to users.

๐ŸŒˆ HSV to RGB Conversion

A custom function, HSVtoRGB, is defined to convert Hue-Saturation-Value (HSV) color values to Red-Green-Blue (RGB) color values. This function is used to generate the rainbow color transition.

๐ŸŽฏ Main Function

In the main function:

  • We create an SFML window of size 800x600 pixels.
  • We define an SFML Clock to measure time.
  • An sf::RectangleShape named rectangle is created, initially covering the entire window.

๐ŸŒŸ Rainbow Transition

Inside the main loop:

  • We calculate the current color based on elapsed time, resulting in a smooth color transition.
  • The color transition speed can be adjusted by changing the factor used in fmod(time * 50, 360).
  • The setFillColor method is used to set the fill color of the rectangle to the calculated color.

๐ŸŽจ Rendering

We clear the window, draw the rectangle with the current color, and display it.

โ–ถ๏ธ Running the Code

Compile this C++ code with SFML properly linked to your project. When you run the executable, a window will appear, displaying the rainbow transition effect on a rectangle covering the entire window.

Feel free to adjust the code parameters, such as the window size or color transition speed, to customize the effect according to your preferences.


๐Ÿ“… Date and Time: '2023/09/01-10:50pm'

Note: If you encounter any issues with missing DLLs or errors, ensure that you have the necessary SFML DLLs in the same directory as your executable or in a directory included in the system's PATH environment variable.

Happy coding! ๐Ÿš€

About

The "Rainbow Transition with SFML" code is a C++ program that utilizes the Simple and Fast Multimedia Library (SFML) to create an engaging visual effect.


Languages

Language:C++ 100.0%