Fractal Docs
A module for viewing fractals
Basic usage:
heighway = HeighwayDragon()
heighway.iterate(15) # More than 15 iterations can cause crashing
heighway.plot()
The fractals available are
BinaryTree
#
Bases: DragonFractal
Creates Binary Trees Based off of Larry Riddle's Webpage
See Documentation for DragonFractal for implementation details and attached resource for creation Details
Source code in fractal.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
DragonFractal
#
Bases: Fractal
A class used to draw and calculate Fractals that require nans inbetween segments
Based loosely on research by Larry Riddle
Source code in fractal.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
Flowsnake
#
Bases: DragonFractal
Flowsnake inheriting from :class:~fractal.DragonFractal
Source code in fractal.py
637 638 639 640 641 642 | |
Fractal
#
A class used to draw and calculate Fractals.
Fractals can be generated by using one of the premade classes, or by creating a new fractal with arbitrary starting points and functions. Note: The majority of funtion systems don't result in fractals.
Once created, fractals are iterated using (index.md#Fractal.iterate)
Based on research by Larry Riddle
Attributes#
S : list[complex]
Default S0 = (0 + 0j) to (1 + 0j)
the current points of the fractal
func_list : list[functions]
the functions to be applied every iteration
Methods#
iterate(i: int) Applies func_list to the current points, S, and updates S to match
plot() Plots the points S using matplotlib
save_gif(iterations: int, duration: int = 1000) saves a gif at 'name _iterations.gif' with a frame duration of duration milliseconds
Source code in fractal.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
__init__(S0, func_list)
#
Parameters#
S0 : list[complex] The initial points to iterate func_list : list[Callable] A list of funtions that determines the function system
Returns#
Fractal
Source code in fractal.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
iterate(i)
#
maps the functions to S, reassigning S
if used with the gif package clears the plot list (ensures proper gif plotting) appends S back to plot list
Parameters#
i : int The number of iterations to advance from the current state
Returns#
None
Source code in fractal.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
plot(autoscale=True)
#
Plots the fractal for human viewing
Source code in fractal.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
save_gif(iterations, duration=1000)
#
Create a gif with a specific duration in milliseconds
Parameters#
iterations : int the number of iterations to include duration : int, optional The time in milliseconds for the gif to run. The default is 1000.
Returns#
None
Source code in fractal.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
translate(offset, angle)
#
Translate and rotate the fractal in the complex plane
Parameters#
offset : complex The vector to use as offset angle : float The angle (in radians) to rotate
Returns#
None
Source code in fractal.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
FudgeFlake
#
Bases: Terdragon
Fudgeflake Fractal inheriting from :class:fractal.Terdragon
Source code in fractal.py
540 541 542 543 544 545 546 547 | |
GoldenDragon
#
Bases: DragonFractal
Golden Dragon Fractal inheriting from :class:~fractal.DragonFractal
Source code in fractal.py
522 523 524 525 526 527 528 | |
GoldenFlake
#
Bases: BinaryTree
Source code in fractal.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
HeighwayDragon
#
Bases: DragonFractal
Heighway Dragon Fractal inheriting from :class:~fractal.DragonFractal
Source code in fractal.py
505 506 507 508 509 510 | |
KochFlake
#
Bases: Fractal
Koch Flake inheriting from :class:~fractal.Fractal
Note: this is constructed as a koch curve, then tiled.
Source code in fractal.py
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |
LevyC
#
Bases: Fractal
Levy C Curve inheriting from :class:~fractal.Fractal
Source code in fractal.py
550 551 552 553 554 555 556 | |
LevyTapestryInside
#
Bases: LevyC
Levy Tapestry inheriting from :class:~fractal.LevyC
Source code in fractal.py
568 569 570 571 572 573 574 575 576 | |
LevyTapestryOutside
#
Bases: LevyC
Levy Tapestry inheriting from :class:~fractal.LevyC
Source code in fractal.py
559 560 561 562 563 564 565 | |
Pentadendrite
#
Bases: Fractal
Pentadendrite inheriting from :class:~fractal.Fractal
Source code in fractal.py
600 601 602 603 604 605 606 | |
Pentigree
#
Bases: Fractal
Pentigree inheriting from :class:~fractal.Fractal
Source code in fractal.py
614 615 616 617 618 619 620 621 622 623 624 | |
Terdragon
#
Bases: Fractal
Terdragon Fractal inheriting from :class:~fractal.Fractal
Source code in fractal.py
531 532 533 534 535 536 537 | |
TwinDragon
#
Bases: DragonFractal
Twin Dragon Fractal inheriting from :class:~fractal.DragonFractal
Source code in fractal.py
513 514 515 516 517 518 519 | |