Fractal | A simple fractal pattern in python with pygame | Machine Learning library
kandi X-RAY | Fractal Summary
kandi X-RAY | Fractal Summary
A simple fractal pattern in python. Prerequisites: Python3 pygame (pip install pygame) numpy (pip install numpy).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Fractal
Fractal Key Features
Fractal Examples and Code Snippets
Community Discussions
Trending Discussions on Fractal
QUESTION
I am writing code to visualize Mandelbrot sets and other fractals. Below is a snippet of the code that is being run. The code runs perfectly fine as is, but I am trying to optimize it to make higher resolution images faster. I've tried using caching on fractal()
, along with @jit
and @njit
from Numba. Caching resulted in a crash (from memory overflow I'm assuming) and @jit
just slows down the execution of my program by a factor of 6. I am also aware of the many mathematical ways there are of making my code run faster, as I've seen on the Wikipedia page, but I would like to see if I can get one of the above methods or some alternative to work.
For creating multiple images in a row (to make a zoom animation, like this one) I've implemented multiprocessing (which seems to run 9 processes at once) but I don't know how to implement the same in the creation of a single high resolution image.
Here is my code snippet:
...ANSWER
Answered 2021-May-12 at 14:48This older answer deals specifically with vectorization, but some additional optimization can be done.
You can start with Numpy vectorization, convenient but not really fast:
QUESTION
I'm trying to create Stochastic Divergences and I don't really like the available open source scripts. The question is how do I obtain the highs and lows below 30 and above 70 lower and upper limits only? That way I could compare them to their price above and there we go with the divergences. I'm not really interested in what's between those limits because it's inaccurate. Most of the scripts are using fractals, but I want specifically the outer highs/lows. Could you please share your experience on how to find those?
...ANSWER
Answered 2021-May-10 at 18:43Could use something like this:
QUESTION
I've gotten some code thrown together that will go through a folder, open all images with a certain ending, and create a histogram of them with ImageMagick. What I can't do (and maybe this is a conceptualization issue as I'm still fairly new to this), is figure out how to record that into a spreadsheet, ideally with the filename attached. PyXl seems to work with Pandas and Numpy, but I can't figure out the path to take this output and record it.
Is there a solution to take the histogram output and record it in a spreadsheet?
Edit: Adding my code thus far. Operating in Windows 10 Pro, using VSCode.
...ANSWER
Answered 2021-Apr-21 at 11:19On reflection, I think I would probably do it with PIL, wand or OpenCV rather than parse the output of ImageMagick which is a bit ugly and error-prone. I have not worked out a full answer but these ideas might get you started:
Rather than use a lossy JPEG for your palette of colours, I would suggest you use a loss-less PNG or GIF format. You can make the (tiny) palette file for remapping with a command like:
QUESTION
I am looking for a function to create fractal sequences in R, and I wondered if there are convenience functions built-in into R to do this.
Let's say, I would like to create the following fractal sequence:
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Code
I could write a simple function to create the fractal sequence:
...ANSWER
Answered 2021-Apr-13 at 13:32You can use sequence
function in base R :
QUESTION
I am working on a project that uses a form of the recursive division algorithm that is normally used to create a fractal-like maze. Now I would like to cite the creator/author of this algorithm to give them credit, but I am unsure who invented it.
Jamis Buck has a very famous blog entry https://weblog.jamisbuck.org/2011/1/12/maze-generation-recursive-division-algorithm , that is titled: "A novel method for generating fractal-like mazes is presented, with sample code and an animation" but did he actually came up with that idea? I do not understand his post as that he invented it, to me it sounds more like he is just describing it.
I was not able to find a clear publication/author through Google and Wikipedia(en) or any other specifically maze-focused site. Does anyone know about the origin of this algorithm?
...ANSWER
Answered 2021-Mar-12 at 13:33No, the algorithm is not mine; I learned it from Walter Pullen’s page, here: https://www.astrolog.org/labyrnth/algrithm.htm. He also does not cite an author for this algorithm. It should be noted that many maze algorithms are adaptations of more general graph algorithms, so it could be that this one has an analog in graph theory somewhere...
At any rate, it’s not mine. I used the word “novel” in my post in the second sense given here (https://www.merriam-webster.com/dictionary/novel) “original or striking especially in conception or style”, not in the sense of “new”.
QUESTION
I am writing a program, which draws the Mandelbrot set. For every pixel, I run a function and it returns an activation number between 0 and 1. Currently, this is done in a fragment shader and activation is my color.
But Imagine you zoom in on the fractal, suddenly all the activations you can see on the screen are between .87 and .95. You can't see the difference very well.
I am looking for a way to first calculate all the activations and store them in an array then based on that array choose the colors. Both of those need to run on the GPU for performance reasons.
...ANSWER
Answered 2021-Mar-01 at 22:00So you need to find minimum and maximum intensity of a picture you've rendered. This cannot be done in a single draw, since these values are nonlocal. A possible way to do this is to recursively apply a pipeline that downscales an image in half, computing the minimum and maximum values of 2x2 squares and storing them e.g. in an RG texture (kind of mipmap generation, with min/max instead of averaging colours). In the end you have a 1x1 texture which contains the minimal and maximal values of your image in its only pixel. You can sample this texture in the final render that maps activation values to colours.
QUESTION
I was watching a video by Aperture on youtube: https://youtu.be/1w40fxsyraE?t=325
At the provided timestamp (5:25), he begins talking about a way to create a fractal. I tried to replicate this in a python program, but I am getting a different output. I have no idea why I am getting this output, but the math seems right, so I don't know what to change. Can anyone explain why my output looks different than the one in the video?
...ANSWER
Answered 2021-Feb-27 at 04:52I watched the video and played with your code and can't see the inconsistency. But looking further afield, I found that by changing your x
(corner selection) from being cyclic, to instead being random, it works fine:
QUESTION
i've been recently getting up to scratch with Javascript, and i have been following along with The Coding Train's video about fractal trees in p5js (this video here https://www.youtube.com/watch?v=0jjeOYMjmDU).
However, i've been having trouble getting the angle slider to actually work since it doesn't seem to be updating at all whenever i move it (at the video at roughly 10m 15s, his seems to work almost without any issues!)
is there anyone who could shed some light on this issue? my code below is as follows:
...ANSWER
Answered 2021-Feb-26 at 20:08When I'm running your p5 sketch I'm getting a recursion error:
Uncaught RangeError: Maximum call stack size exceeded (sketch: line 24)
Your branch function never returns as it calls itself infinite times. I made some edits, also see my inline comments.
QUESTION
I am studying a pattern that ended up having a fractal nature. I wrote a function that handles the case when n=4. It looks something like this:
...ANSWER
Answered 2021-Feb-23 at 06:01You can carry the varying part as a parameter.
QUESTION
I am trying to separate a float into it's integral and fractal parts. My method works fine for some values, but does not when I encounter a value that has a longer decimal representation.
...ANSWER
Answered 2021-Feb-19 at 10:49You want to get the the parts from the exponent display form so for 2.435343454e36 it will be 2
and 0.435343454
If yes toy need to "normalize" your number (remove the e
part). Then you can use your formulas to get the number parts
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Fractal
You can use Fractal like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page