{"id":20126634,"url":"https://github.com/mrsloth-dev/42-fractol","last_synced_at":"2026-05-12T00:45:22.597Z","repository":{"id":251996713,"uuid":"838990681","full_name":"MrSloth-dev/42-Fractol","owner":"MrSloth-dev","description":"A Graphical Project for rendering Fractals","archived":false,"fork":false,"pushed_at":"2024-09-15T23:36:20.000Z","size":6053,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T08:12:48.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrSloth-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-06T18:39:29.000Z","updated_at":"2024-10-25T13:28:26.000Z","dependencies_parsed_at":"2024-08-07T03:04:52.601Z","dependency_job_id":"812e633f-173a-48ee-a725-710fb0aef4be","html_url":"https://github.com/MrSloth-dev/42-Fractol","commit_stats":null,"previous_names":["mrsloth-dev/42-fractol"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrSloth-dev%2F42-Fractol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrSloth-dev%2F42-Fractol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrSloth-dev%2F42-Fractol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrSloth-dev%2F42-Fractol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrSloth-dev","download_url":"https://codeload.github.com/MrSloth-dev/42-Fractol/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241570921,"owners_count":19984002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:17:06.467Z","updated_at":"2026-05-12T00:45:22.569Z","avatar_url":"https://github.com/MrSloth-dev.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to Fract-ol\n\u003cp align=\"center\"\u003e\nThis project is the first graphical project in 42's Common Core.\n\u003cimg src=\"https://raw.githubusercontent.com/MrSloth-dev/42-Fractol/main/assets/julia.jpeg\" width=\"800\" height=\"600\" border=\"10\"/\u003e\n\u003c/p\u003e\n  \n\u003c/p\u003e\n\n# How to use\n\nFirst :\n```\ngit clone https://github.com/MrSloth-dev/42-Fractol.git\n```\n\nThen you need to Download and configure to your machine the MinilibX (LINUX ONLY)\n```\nmake mini\n```\nNow execute make to compile\n```\nmake\n```\nUsage :\n```\n./fractol \u003cname_of_fractal\u003e\n```\n#### Note: Inside there is a menu that you can open if 'h' is pressed.\n\n#### Note: Julia Set need 2 more arguments, the real component and the imaginary. For example : ./fractol julia -0.8 0.156 .[^1].\n\n## Makefile Rules\n```\nmake - Compile fractol files.\n\nmake mini - Download MiniLibX and configure it to the currrent PATH\n\nmake clean - Delete all .o (object files) files.\n\nmake fclean - Delete all .o (object files) and .a (executable) files.\n\nmake re - Use rules fclean + all.\n\nmake debug - add -g flag to compilation and rebuild.\n```\n\n## How Does it Work?\n\nThe program is divided by 5 main parts: TODO: extend the explanation in each point, always in pseudocode and with references\n1. The analysis of the input\n    1. As stated by the subject [see [here]()], the program must be able to reproduce the Julia Set and Mandelbrot.\n        - The usage will be ./fractol \u003cname of the fractal\u003e, but to complete the Julia Set we need to give the arguments of the initial condition.[^2]\n        - In my case I did also the Quartic and Newton Fractals.\n    2. To accept (float/double) numbers as arguments we need to improve our atoi into an Ascii to (float / double) NOTE: I used double to ensure less error when dealing with small numbers. NOTE: I used double to ensure less error when dealing with small numbers.\n2. Creating the environment\n    1. Because we are using MiniLibx, we need to take care of creating the display, the window and the image, with mlx_init(), mlx_new_window(), mlx_new_image() respectively.\n    2. Because the mlx_putpixel has some issues with performace we need to create a new put pixel directly to out image. We call it my_mlx_put_pixel()\n3. Calculate the iteractions and color\n    1. For understanding better how the fractals representation is rendered check this video.[Youtube](https://www.youtube.com/watch?v=uc2yok_pLV4)\n        - The number of iterations is calculated by the number of times that the mod squared:\n        $$ Real^2 + Imag^2 $$ excceed the value of 4 ($$ 2^2 $$), this is like Pyhtagoreas Theorem to measure the distance between two points, by having the coordinates. In our case the coordinates are x for the Real part of the complex number and y for the imaginary.\n        - In Mandelbrot and Julia, the sequence to calculate the iterations is $$ Zn+1 = Zn^2 +c $$, note that Z and c are complex numbers so we need to do a more complex (pun intended) calculations, like Polynomials.j\n        - For Newton Fractal we have $$ z - {0.5 * z^3 - 1\\over   3*z^2} $$\n        - For Quartic Fractal we have $$ z^4 + c $$\n    2. Now that we understand how to calculate the number of iterations, the Color calculation is easier.\n        - The Color is an int represented in Hexadecimal, so 0x000000 is equal to 0 and the color BLACK. and 0xffffff is equal to 16777215 and the color WHITE.\n        - It's easier to understand the colors as number if we represent 0x ff ff ff, as 0x is telling us that the number is in hexadecimal the first ff is the RED the second ff is the GREEN and the third is the BLUE, so if you add them we have.... [RGB](https://www.google.com/url?sa=t\u0026source=web\u0026rct=j\u0026opi=89978449\u0026url=https://pt.wikipedia.org/wiki/RGB\u0026ved=2ahUKEwicsKbYxOWHAxWIRqQEHSH-DZYQFnoECBMQAQ\u0026usg=AOvVaw1b0slebKyncPhmU0yrybU8)!\n        - So if we have a range of color between BLACK and WHITE and we have max iterations of 100 p.e.\n            - We convert the number of iterations inside our range of iteration (0 \u003c iter \u003c max_iter) to a new range of color (BLACK \u003c calculated_number \u003c WHITE)\n            - NOTE: To improve the performance of our program the number should be lower, because each pixel will be calculated that number of times\n4. Render the Fractals\n    1. Because the range of our coordinates between our window and the mandelbrot is different, we need to handle that conversion llike we did previously with the color.\n        - For example in my case I had a window of (800x600) so we have 0 \u003c x \u003c 800 and 0 \u003c y \u003c 600, and in the mandelbrot we got  -2 \u003c x,y \u003c 2 in both axis.\n    2. For future reference in this convertion we need to add the scale (zoom) and offset_value (arrow keys) for consistency of the range showed in the window.\n4. Handle Events\n    1. For this project we need to implement some features, like Mouse scroll for zoom and arrow keys (or WASD) for movement. Another extra feature that was asked was a \"follow the mouse\" zoom.\n\n\n[^1]: Please visit the [Wikipedia](https://en.wikipedia.org/wiki/Julia_set)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsloth-dev%2F42-fractol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrsloth-dev%2F42-fractol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsloth-dev%2F42-fractol/lists"}