Shape Pattern Generator
Description
A simple C++ application that generates an animated grid of colorful shapes (circles, squares, triangles). The patterns are designed to be visually engaging, with repeating but variable sequences, shifting colors, and periodic regeneration of the entire grid.
This project uses Raylib for graphics rendering and CMake for the build system. It's intended as a fun visual toy, particularly inspired by a request for an autistic child who enjoys such patterns.
Features
- Displays a dynamic grid of shapes (circles, rectangles, triangles).
- Randomized shape types and base colors for variety.
- Smooth hue-shifting color animation for each shape.
- Periodic regeneration of the entire pattern for continuous visual interest.
- Cross-platform (thanks to Raylib and CMake).
- Simple to compile and run.
Dependencies
To build and run this project, you'll need the following:
- Raylib: A recent version (e.g., 4.5, 5.0).
- The
CMakeLists.txt
is configured to find Raylib viafind_package
(if installed system-wide orCMAKE_PREFIX_PATH
is set) or by building it from araylib
subdirectory (e.g., added as a Git submodule).
- The
- CMake: Version 3.15 or higher.
- C++ Compiler: A C++17 compatible compiler (e.g., Clang, GCC, MSVC).
- System Libraries (Mainly for Linux):
- On Linux, Raylib has dependencies on various X11 and OpenGL libraries. Based on experience and common requirements, you might need to install development packages such as:
libx11-dev
libxrandr-dev
libxinerama-dev
libxcursor-dev
libxi-dev
libgl1-mesa-dev
(or equivalent for your OpenGL drivers)libasound2-dev
(for audio, though not used in this specific version, Raylib might link it)- For Wayland-based systems, dependencies might differ (
libwayland-dev
, etc.).
- Please refer to the official Raylib documentation for the most up-to-date and comprehensive list of dependencies for your specific operating system and distribution.
- On Linux, Raylib has dependencies on various X11 and OpenGL libraries. Based on experience and common requirements, you might need to install development packages such as:
Build Instructions
-
Clone the Repository: If you have this project in a Git repository, clone it. Otherwise, ensure
main.cpp
andCMakeLists.txt
are in your project's root directory. -
Get Raylib:
- If using
find_package
: Ensure Raylib is installed where CMake can find it (e.g., system-wide, or by settingCMAKE_PREFIX_PATH
during CMake configuration). - If building Raylib as a subdirectory: Clone the Raylib library into a subdirectory named
raylib
within your project root:git submodule add [https://github.com/raysan5/raylib.git](https://github.com/raysan5/raylib.git) raylib # Or download and extract Raylib source into a 'raylib' folder.
- If using
-
Configure with CMake: Create a build directory and run CMake from there. To use Clang:
mkdir build cd build cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
- If Raylib is installed in a custom location and you're not using the subdirectory method, you might need to tell CMake where to find it:
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_PREFIX_PATH=/path/to/your/raylib_install_directory
- If Raylib is installed in a custom location and you're not using the subdirectory method, you might need to tell CMake where to find it:
-
Compile the Project: While still in the
build
directory:cmake --build .
Or, you can use
make
(orninja
, etc., depending on the generator CMake used):make
-
Run the Application: The executable will be generated in the
build
directory (e.g.,ShapeGenerator
on Linux/macOS,ShapeGenerator.exe
on Windows)../ShapeGenerator
How to Use
- Launch the application after building it.
- A window will appear displaying the animated shape patterns.
- Press the
ESC
key to close the application window.
Tinkering
Feel free to modify the source code (main.cpp
) to:
- Change color palettes or animation speeds.
- Add new shapes or behaviors.
- Adjust grid size or regeneration timings.
- Experiment with different Raylib features.
This project was inspired by a desire to create a simple, visually engaging application.