Git Product home page Git Product logo

fractalplotr's People

Contributors

farbfetzen avatar

Watchers

 avatar

fractalplotr's Issues

Experiment with gifs and movies

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.

convenience functions for rotating and mirroring of the fractals

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.

Plot dragon curve function

Custom function for plotting dragon curve with reasonable defaults and some modifications to par(mar) etc. Make sure to reset par using on.exit().

Determine matrix size for sandpile before iteration

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.

Improve the speed

Profile the code first to see where the bottlenecks are. Maybe use the parallel package.

stop github from displaying the pictures larger than they are

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.

OOP magic for plotting

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.

Separate plotting and exporting.

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.

Write a comprehensible manual

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.

notes on color

  • Find a better solution for the color palette argument. less verbose for the user.
  • Look at zlim argument of image function. could be usefull for color normalization.
  • Check out the other arguments to colorRampPalette.
  • Try out the viridis colour package https://github.com/sjmgarnier/viridis.
  • Implement interesting constants and coordinates as function calls.

1.0 checklist

  • Either fix the mandelbrot coloring or remove the broken coloring from this version and put it into 1.1.
  • Bump version number.
  • Write NEWS.md
  • All tests successful
  • Documentation complete
  • R CMD check successful
  • Tag v1.0 with git: https://git-scm.com/book/en/v2/Git-Basics-Tagging This should automatically create a "release" in GitHub.
  • Check the DESCRIPTION.
  • Make sure that the examples run fast, don't produce big images and certainly don't modify/create any files.
  • This package will never go on CRAN but follow the guidelines regardless. Don't modify the global namespace, don't change options, don't touch par, etc.
  • Replace the placeholder documentation in fractalplotr.R
  • Review all TODO, FIXME, print(), etc. Source files must not contain any of those. Convert to issues if necessary.
  • Decide on a naming scheme for the fractal functions. Is it "dragon" or "dragon_curve"? "mandelbrot" vs. "mandelbrot_set"? "sierpinski-triangle" or simply "sierpinsky"? But keep it at one name only per fractal and don't define aliases. I'm leaning more towards the shorter versions.
  • Update the README.md and the images in it.

Clean and commit example_pictures.

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?

Improve memory footprint of package

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.

Loop colors

This would be useful for zoom sequences. But make it optional!

Enable multipanel plotting of color_matrix objects

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.

ulam-warburton_cellular-automaton

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)

Major cleanup needed

These scripts are years old and are in dire need of a good scrubbing.

  • The main fractal functions (mandelbrot() and sandpile()) should provide an argument to control whether a color matrix is returned or just the results of the iterations.
  • Put license info at the top of every script. See the bottom of the license file for the boilerplate.
  • Review the code style.
  • Limit line length to 80 characters. Change the margin in the RStudio options.
  • No code execution at the top level.
  • Separate overly long and complex functions into smaller ones.
  • Improve the docstrings. Look up how other people do this.
  • Look at the TODOs at the bottom of fractals.R
  • Remove magic numbers where possible, e.g. the standard_limits list.
  • Use TRUE and FALSE instead of T or F.
  • Separate mandelbrot and julia set into their own functions and scripts.
  • Remove source() and remember to never use it in a package.
  • Always use on.exit() when modifying par().
  • Give the functions better names.
  • Take fractal_generation.R apart. Remove the unnecessary stuff and use the rest for examples in maybe a vignette or help files.
  • Think about which functions to export. Only bother with argument checking and help pages on those.

Julia sets

Maybe re-use some code from the mandelbrot set. Isn't the coloring similar?

use readme.rmd

Use usethis::use_readme_rmd() to make a readme with automatically created and inserted example pictures.

Coordinate conversion

Provide an easy way to specify coordinates for mandelbrots and related fractals. There should be several valid ways for users to specify coordinates:

  • top, left, width, height
  • center, width, height
  • top, left, bottom, right

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.

L-system enhancements

  • Make it possible to modify the line length.
  • Make an S3 method for plotting, same as for the other fractals.
  • Export some interesting and/or beautiful systems. Same way like any other builtin data set.

Various fixes

  • Add --as-cran to Check arguments.
  • Add the correct imports. See http://r-pkgs.had.co.nz/namespace.html#imports
  • Fix the license: remove the license file and the license field from the description and then do usethis::use_gpl3_license.
    or buildignore the license file and remove the "file license" from description manually

Zoom and floating point numbers

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.

testing and argument checking

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.