{"id":24895220,"url":"https://github.com/jcocozza/go_fractals","last_synced_at":"2025-03-27T15:25:18.266Z","repository":{"id":193959563,"uuid":"689721280","full_name":"jcocozza/go_fractals","owner":"jcocozza","description":"Code to build fractals in Go","archived":false,"fork":false,"pushed_at":"2024-04-16T21:29:11.000Z","size":28453,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T19:16:59.618Z","etag":null,"topics":["fractals","go","iterated-function-system","julia-sets","mandelbrot-set"],"latest_commit_sha":null,"homepage":"","language":"Go","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/jcocozza.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":"2023-09-10T17:42:43.000Z","updated_at":"2023-12-06T17:39:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"4a157471-3e04-4200-badd-16d56dcfdab9","html_url":"https://github.com/jcocozza/go_fractals","commit_stats":null,"previous_names":["jcocozza/go_fractals"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcocozza%2Fgo_fractals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcocozza%2Fgo_fractals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcocozza%2Fgo_fractals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcocozza%2Fgo_fractals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcocozza","download_url":"https://codeload.github.com/jcocozza/go_fractals/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245869774,"owners_count":20685904,"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":["fractals","go","iterated-function-system","julia-sets","mandelbrot-set"],"created_at":"2025-02-01T19:17:12.478Z","updated_at":"2025-03-27T15:25:18.226Z","avatar_url":"https://github.com/jcocozza.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fractal Generator\n![image](./examples/images/example.png)\n\nBuild fractals with a cli:\n```\n$ go_fractals --help\nA Command Line Application to build fractals in Go.\n\nUsage:\n  go_fractals [command]\n\nAvailable Commands:\n  completion   Generate the autocompletion script for the specified shell\n  help         Help about any command\n  ifs          Access Iterated function system commands\n  julia        create a julia set\n  julia-evolve evolve a julia set through a parameter\n  mandelbrot   create a mandelbrot set\n\nFlags:\n  -F, --fileName string   [OPTIONAL] Set file name (default \"fractalOutput\")\n  -f, --fps int           [OPTIONAL] The framerate of the video. (default 10)\n  -H, --height int        [OPTIONAL] Set height (default 1000)\n  -h, --help              help for go_fractals\n  -W, --width int         [OPTIONAL] Set width (default 1000)\n\nUse \"go_fractals [command] --help\" for more information about a command.\n```\n\n# Iterated Function Systems\n\n## Usage\n\n```\n$ go_fractals ifs --help\nAccess Iterated function system commands\n\nUsage:\n  go_fractals ifs [command]\n\nAvailable Commands:\n  evolve      iterate through an ifs\n  image       Run an iterated function system\n\nFlags:\n      --algo-d                       [OPTIONAL] Use the deterministic algorithm (default true)\n      --algo-p                       [OPTIONAL] Use the probabilistic algorithm\n  -h, --help                         help for ifs\n  -n, --numItr int                   [OPTIONAL] The number of iterations you want to use. (default 1)\n  -z, --numPoints int                [OPTIONAL] The number of initial points. (default 1)\n  -k, --numStacks int                [OPTIONAL] The number of stacks to generate (default 1)\n  -p, --path string                  [REQUIRED] The path to your iterated function system file\n      --probabilities float64Slice   [OPTIONAL - comma separated] Specify probabilities of transformations. Must add to 1. If none will calculated based on matrices. Note that a determinant of zero can cause unexpected things. (default [])\n  -T, --thickness float32            [OPTIONAL] Specify the thickness the stack layer (default 15)\n\nGlobal Flags:\n  -F, --fileName string   [OPTIONAL] Set file name (default \"fractalOutput\")\n  -f, --fps int           [OPTIONAL] The framerate of the video. (default 10)\n  -H, --height int        [OPTIONAL] Set height (default 1000)\n  -W, --width int         [OPTIONAL] Set width (default 1000)\n\nUse \"go_fractals ifs [command] --help\" for more information about a command.\n```\n\n## Building Fractals with Iterated Function Systems\n\nThe CLI tool revolves around the user generated file (you can call it whatever you like when you pass it into the CLI).\n\nHere's what a sample file, `ifs.txt`, looks like:\n```\n[2,2][.5,0,0,.5] + [2,1][0,0]\n[2,2][-.5,0,0,.5] + [2,1][1,0]\n[2,2][.5,0,0,-.5] + [2,1][0,1]\n[2,2][.25,0,0,.25] + [2,1][.75,.75]\n```\n\nEach newline represents a new transformation in the system. Information about the transformation is encoded in the following way:\n\n```\n[2,2][.5,0,0,.5] + [2,1][0,0] -\u003e\n[number_of_rows, number_of_columns][similiarity_matrix] + [number_of_rows, number_of_columns][shift_matrix]\n```\n\nSo, if we look at `[2,2][.5,0,0,.5], we see this is a 2x2 matrix.` When ordering elements of the matrix, start in the first row, and go across columns, then go tho the second row and so on.\n\nSo the identity matrix is:\n```\n[ 1 0 ]\n[ 0 1 ]\n```\n\nIs represented as `[2,2][1,0,0,1]`.\n\nNote that shifts should always have a `number_of_columns = 1`, since you are simply moving the points.\n\n## Example\n\nHere are several ways to generate the Barnsley fern which is represented by the following IFS:\n\n```\n[2,2][0,0,0,.16] + [2,1][0,0]\n[2,2][.85,0.04,-.04,.85] + [2,1][0,1.6]\n[2,2][0.2,-.26,.23,.22] + [2,1][0,1.6]\n[2,2][-.15,.28,.26,.24] + [2,1][0,.44]\n```\n\nThe deterministic algorithm:\n1) `$ go_fractals ifs image -p examples/barnsley_fern_ifs.txt --algo-d -n 13`\n\nThe probabilistic algorithm:\n\n2) `$ go_fractals ifs image -p examples/barnsley_fern_ifs.txt --algo-p -n 67108864`\n\nThe probabilistic algorithm with custom probabilities for each transformation (This will do a better job of adding the stem compared to the probabilistic algorithm alone):\n\n3) `$ go_fractals ifs image -p examples/barnsley_fern_ifs.txt --algo-p -n 67108864 --probabilities .1,.67,.115,.115`\n\nAnd here it is:\n\n![image](./examples/images/barnsley_fern.png)\n\n\n## .stl files:\n\n### Stacks\n\nTo be Done... currently do not work. (Although you can generate some cool looking things with the `--threeDim` flag regardless)\n\n## Videos\n\nYou can also generate videos of fractals developing:\n\n![gif](./examples/images/example.gif)\n\n## Random Fractals\n\nThis did not work out the way I expected and need refinement. Currently, you rarely get anything interesting.\nMost of the time they aren't fractals in the rigorous sense.\n\n![image](./examples/images/random_fractal.png)\n\n\n## A full suite - The maple fractal:\n```\n[2,2][.15,0,0,.5] + [2,1][-.125,-1]\n[2,2][.4,.4,-.5,.5] + [2,1][1.2,-.75]\n[2,2][.4,-.4,.5,.5] + [2,1][-1.4,-.73]\n[2,2][.5,0,0,.5] + [2,1][.01,1.5]\n```\n\n### Deterministic\n```\n$ go_fractals ifs image -p maple.ifs --algo-d -n 11\nTotal number of points: 4194304\nElapsed time for Deterministic algorithm: 1.121766417s\n```\n![image](./examples/maple/maple_deterministic.png)\n\n### Probabilistic\n(using same # of points as deterministic, hence: `-n 4194304`)\n```\n$ go_fractals ifs image -p leaf.ifs --algo-p -n 4194304\nprobabilities: [0.06666666666666667 0.35555555555555557 0.35555555555555557 0.2222222222222222]\nTotal number of points: 4194305\nElapsed time for Probabilistic algorithm: 8.189872041s\n```\n![image](./examples/maple/maple_probabilistic.png)\n\n### Video\n```\n$ go_fractals ifs evolve -p leaf.ifs --algo-d -n 11 --fps 3\n```\n![gif](./examples/maple/maple_video.gif)\n\n### Stack\n```\n$ go_fractals ifs evolve -p maple.ifs --threeDim -k 1 -T 50 -n 1000000 --algo-p\n```\n![image](./examples/maple/maple_stack.png)\n\n# Julia Sets\n\nUsing the escape time algorithm `go_fractals` also provides the ability to build Julia sets.\n\n## Usage\n\nThere are two julia commands, a regular julia set and julia parameter evolution.\n\n```\n$ go_fractals julia --help\nPass in a complex function for the julia set\n\nUsage:\n  go_fractals julia [flags]\n\nFlags:\n  -p, --centerPoint string   [Optional] Set the center point for the fractal (default \"0+0i\")\n  -c, --color                [OPTIONAL] Default Grey Scale\n  -e, --equation string      [REQUIRED] The equation for your julia set\n  -h, --help                 help for julia\n  -m, --maxItr int           [OPTIONAL] Set max iterations for time escape (default 1000)\n  -z, --zoom float           [OPTIONAL] Set the zoom; smaller value is more zoomed in (default 4)\n\nGlobal Flags:\n  -F, --fileName string   [OPTIONAL] Set file name (default \"fractalOutput\")\n  -f, --fps int           [OPTIONAL] The framerate of the video. (default 10)\n  -H, --height int        [OPTIONAL] Set height (default 1000)\n  -W, --width int         [OPTIONAL] Set width (default 1000)\n```\n\n```\n$ go run . julia-evolve --help\nCreate a video or 3d stl of the julia set evolving through parameter space\n\nUsage:\n  go_fractals julia-evolve [flags]\n\nFlags:\n  -b, --binary                    [OPTIONAL] save the stl as a binary\n  -p, --centerPoint string        [OPTIONAL] Set the center point for the fractal (default \"0+0i\")\n  -i, --complexIncrement string   [REQUIRED] Set the increment for the evolution of the parameter\n  -e, --equation string           [REQUIRED] The parameterized equation for your julia set\n  -f, --fps int                   [OPTIONAL] The framerate of the video. (default 10)\n  -h, --help                      help for julia-evolve\n  -P, --initialComplex string     [REQUIRED] Set the intial parameter for a julia evolution\n  -m, --maxItr int                [OPTIONAL] Set max iterations for time escape (default 1000)\n  -n, --numIncrements int         [REQUIRED] the number of evolution steps to take (default 10)\n  -s, --solid                     [OPTIONAL] write the stl as a completely solid object(much larger file size)\n  -d, --threeDim                  [OPTIONAL] Create a 3d stl file of the evolution\n  -z, --zoom float                [OPTIONAL] Set the zoom; smaller value is more zoomed in (default 4)\n\nGlobal Flags:\n  -F, --fileName string   [OPTIONAL] Set file name (default \"fractalOutput\")\n  -H, --height int        [OPTIONAL] Set height (default 1000)\n  -W, --width int         [OPTIONAL] Set width (default 1000)\n\n```\n\n### Equations\nThe basis for julia sets are the equations you use to build them. I don't have a particularly sophisticated equation parser, but essentially what happens is that your equation will be converted into a golang function. When passing them into the CLI, you need to use golang syntax: `z*z - 2` is the equation `z^2 - 2`.\n\nWhen creating a regular julia set, you must use `z` as the function's variable. (this is a consequence of how the parser is built)\n\nWhen creating julia evolutions, `z` is the function variable and `c` is the parameter that will be evolved. For example, `z*z - c`.\n\n### Regular Julia Set\n\n`$ go_fractals julia -e \"1/(z*z + .72i)\" -F example`\n\n![image](./examples/julia/example.png)\n\n### Julia Evolution\n\nAn evolution associated with the above's fractal set:\n`$ go_fractals julia-evolve -e \"1/(z*z + c)\" -f 10 -P \"0-0.63i\" -n 100 -i \"0-0.001i\" -F example`\n\nWhat this represents is the evolution through parameter space from:\n`1/(z*z + -0.63i)` ⇒ `1/(z*z + -.73i)` in increments of `0.001i`.\n\n![gif](./examples/julia/evolution.gif)\n\nWe can also create 3d stl models of the parameter evolution.\nTry:\n`$ go_fractals julia-evolve -e \"z*z + c\" -P \"-.5+0i\" -n 10 -i \".0625+.0625i\" -F exampleSTL -W 200 -H 200 --threeDim`\n\nNote that this is still very finicky and can produce very large files if you aren't careful.\nBy default we write to an ascii file, but you can also try to write with binary using `--binary`\n\nThe stl models can also produce very cool 3d structures if you choose your path through parameter space well enough.\n\n`$ go_fractals julia-evolve -e \"z*z + c\" -P \"-.5+0i\" -n 65 -i \".008333+.008333i\" -F exampleSTL3d -W 150 -H 150 --threeDim`\n\nIf you have a 3d viewing software, I really recommend taking a look at the [stl file](./examples/julia/exampleSTL3d.stl) for the above generation.\nOnline [this stl viewer](https://www.viewstl.com/#!) was very useful for testing this project.\n\nThough it does not do it credit, here is an image of it.\nYou can just begin to make out the evolution of the Julia sets over parameter space.\n![png](./examples/julia/exampleSTL3d.png)\n\nIf you have access to a 3d printer, that's were the fun really begins.\n3d printed it looks like this:\n![png](./examples/julia/julia_evolution.png)\n\n# Mandelbrot Sets\n\nUsing the escape time algorithm, `go_fractals` provides the ability to build general Mandelbrot sets.\n\n## Usage\n```\n$ go_fractals mandelbrot --help\nPass in a complex function for the mandelbrot set\n\nUsage:\n  go_fractals mandelbrot [flags]\n\nFlags:\n  -p, --centerPoint string   [Optional] Set the center point for the fractal (default \"0+0i\")\n  -c, --color                [OPTIONAL] Default Grey Scale\n  -e, --equation string      [REQUIRED] The equation for your mandelbrot set\n  -F, --fileName string      [REQUIRED] The file name in the downloads folder\n  -h, --help                 help for mandelbrot\n  -m, --maxItr int           [OPTIONAL] Set max iterations for time escape (default 1000)\n  -z, --zoom float           [OPTIONAL] Set the zoom; smaller value is more zoomed in (default 4)\n\nGlobal Flags:\n  -f, --fps int      [OPTIONAL] The framerate of the video. (default 10)\n  -H, --height int   [OPTIONAL] Set height (default 1000)\n  -W, --width int    [OPTIONAL] Set width (default 1000)\n```\n\nEquations are built in the same way as Julia set equations.\n\n### Example\n\nThe classic Mandelbrot set:\n`$ go_fractals mandelbrot -e \"z*z + c\" -F mandelbrot`\n\n![image](./examples/mandelbrot/mandelbrot.png)\n\nThe burning ship:\n`$ go_fractals mandelbrot -e \"complex(math.Abs(real(z)),math.Abs(imag(z)))*complex(math.Abs(real(z)),math.Abs(imag(z))) + c\" -F burningShip`\n\n![image](./examples/mandelbrot/burningShip.png)\n\nThe burning ship, zoomed with color, centered at -1.75 + .025i:\n`$ go_fractals mandelbrot -e \"complex(math.Abs(real(z)),math.Abs(imag(z)))*complex(math.Abs(real(z)),math.Abs(imag(z))) + c\" -F burningZoomColor -p \"-1.75-0.025i\" --color -z .08`\n\n![image](./examples/mandelbrot/burningZoomColor.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcocozza%2Fgo_fractals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcocozza%2Fgo_fractals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcocozza%2Fgo_fractals/lists"}