farbfetzen / fractalplotr Goto Github PK
View Code? Open in Web Editor NEWMake beautiful fractals with R
License: Other
Make beautiful fractals with R
License: Other
A gui where the users can select a fractal and then set the parameters via buttons, numeric input and sliders.
Turn a mandelbrot zoom sequence into a gif or a movie. Try to keep the file size minimal while avoiding compression artefacts and allowing big resolutions.
This thread on stackoverflow might help.
Seems like imagemagick should do the trick. I could use the command line (within R using the system() function). See also the magick package and its vignette.
Experiment with different video and image formats.
An alternative could be ImageJ or GIMP.
rotating: function which either accepts an angle (+- 90 etc.) or a direction and amount of turns ("left", 3). Function for rotating it once gets called multiple times depending on angle or amount of turns.
mirroring: just accepts the direction, i.e. vertical or horizontal
Both must work with the matrices used in the mandelbrot and julia sets and the coordinate matrix of the dragon curve.
Custom function for plotting dragon curve with reasonable defaults and some modifications to par(mar) etc. Make sure to reset par using on.exit().
To stop having to increase the size of the matrix during the loop just make one big matrix at the beginning and then cut off the empty edges afterwards. This would make the code more elegant and maybe improve speed and memory footprint.
Profile the code first to see where the bottlenecks are. Maybe use the parallel package.
How can I avoid that? I want the pictures not larger than their original size! Maybe play around with out.width
? Or remove it? Look at the generated README.md file, where it says <img src="man/figures/README-dragon-1.png" width="100%" />
. What happens if I remove that and then use very large pictures? Does the readme get wider or are they (hopefully) shrinked?
Make sure that it still looks nice on mobile.
Make use of plot
Instead of having a plot_mandelbrot
function. Assign a class mandelbrot or factal to the matrix so the correct plot function is called.
Also I think mandelbrot and julia sets can use the same function because they are closely related.
Currently plot_mandelbrot()
saves an image to disk. This is not advisable because the word plot
is usually not used for that in R. Make a save_mandelbrot()
or save_fractal()
function for that and rewrite plot_mandelbrot()
to just display the fractal.
to check the package and run tests. There seem to be templates for this.
Maybe also use it build the package for windows and linux?
https://github.com/r-lib/actions, see also the additional resources mentioned in the readme there.
Put it into the readme and at the the top of the main script.
Also make a good example script that shows how to use the code.
as it is no longer recommended since testthat version 2.1.0
But do not build it. I mean leave it in buildignore.
These pictures are for the readme on github. Make them low resolution to keep the file size down. They only need to fit in the readme.
Oh and maybe in the vignette?
I could store the color as a string "#FFFFFF"
or as an integer 256**3-1
(both are the same value. But the objects have different sizes.
Is this really necessary? How big are the results anyway? I mean with a sidelength of 2000 * 1000 an integer matrix is only about 8 MB big. And strangely it's the same size for strings. So avoid unnecessary complication in the code if the improvements don't justify it. But be careful not tomake it a double because that is 160MB.
In short: See where the memory footprint of the package can be improved and then see if it is an easy fix or if it is necessary. If not, then don't do it.
using usethis::use_data(..., internal = TRUE)
This would be useful for zoom sequences. But make it optional!
https://en.wikipedia.org/wiki/Mandelbrot_set#Histogram_coloring
Maybe combine with smooth coloring.
See https://en.wikipedia.org/wiki/Mandelbrot_set#Continuous_(smooth)_coloring
Also implement histogram colouring, too.
Reduce the time it takes to generate big sandpiles. Use the symmetry.
Consider using graphics::image()
instead of grid::grid.raster()
because image()
plays nicer with par()
and layout()
.
But beware that image requires more work preparing the matrix, e.g. separating the colors from the coordinates and flipping and rotating.
Call the function uwca
or ulam_warburton
(make those names aliases).
plot_cells <- function(m) {
m <- abs(m - 1) # change 0 to 1 and 1 to 0
grid::grid.newpage()
grid::grid.raster(m, interpolate = FALSE)
}
n <- 64
sidelength <- 2 * n - 1
m <- matrix(0, nrow = sidelength, ncol = sidelength)
m[ceiling(sidelength/2), ceiling(sidelength/2)] <- 1
for (i in seq_len(n - 1)) {
left <- cbind(m[, -1], 0)
right <- cbind(0, m[, -sidelength])
top <- rbind(m[-1, ], 0)
bottom <- rbind(0, m[-sidelength, ])
new <- left + right + top + bottom + m
new[new > 1] <- 0
m <- m + new
m[m > 1] <- 1
}
plot_cells(new)
plot_cells(m)
These scripts are years old and are in dire need of a good scrubbing.
mandelbrot()
and sandpile()
) should provide an argument to control whether a color matrix is returned or just the results of the iterations.source()
and remember to never use it in a package.on.exit()
when modifying par()
.fractal_generation.R
apart. Remove the unnecessary stuff and use the rest for examples in maybe a vignette or help files.Maybe re-use some code from the mandelbrot set. Isn't the coloring similar?
Use usethis::use_readme_rmd()
to make a readme with automatically created and inserted example pictures.
Provide an easy way to specify coordinates for mandelbrots and related fractals. There should be several valid ways for users to specify coordinates:
Make it optional that the aspect ratio ist 1:1. If the user wants a skewed image then let them. But the default should be a ratio of 1:1.
like that one on gitlab
See https://github.com/BastiHz/L-systems. Include some rulests.
usethis::use_gpl3_license
.Try some high zoom levels and check how floating point inaccuracies influence the results. See if there is a way to get arbitrary precision complex numbers.
Write the package in R 3.5 so I can use the better version of stopifnot() with the exprs argument.
Test not only if the functions produce the correct output but also if they throw errors for bad input when necessary. Only test for bad input in exported functions the user can see.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.