Code Monkey home page Code Monkey logo

blazor-fractals's People

Contributors

fernandreu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

blazor-fractals's Issues

Allow running Azure Function locally

The intention would then be to only publish it via the CI/CD workflow, never manually.

CORS will need to be enabled for this. The full argument list in Rider would be:

host start --port 7071 --pause-on-error --cors *

Consider migrating the actual fractal call elsewhere

Some options:

  • AWS Lambda
  • Azure Functions
  • A simple Asp.Net Core server

Azure Functions seems like a good fit. It could just be a simple project under the same solution which refers to the same ApplicationCore project and gets deployed at the same time as the front end.

Perhaps give the option to choose between executing the call locally or not. It would be a pity having to depend on a server just because the computation can be slow and blocks the UI thread.

Add method to simplify math trees

This becomes especially important for derivatives, where their raw application can lead to many terms that could otherwise cancel each other.

Some possible simplifications:

  • (a+b)+c === a + b + c
  • (a*b)*c === a * b * c
  • -(a+b+c) === -a-b-c
  • (-a)*(-b) === a*b
  • (-a)/(-b) === a/b

Switch from raw Bootstrap to BlazorStrap

This would allow using advanced controls (e.g. modals) without having to use (or manage) JavaScript plugins directly, while also ensuring the underlying Bootstrap library is kept up to date.

The transition should be relatively straightforward, provided the naming convention they followed is similar to Bootstrap.

Add a Fractal method

Things it should do:

  • Apply the Newton's method to a range of coordinates and return the results that would make the fractal image

Things it should not do (yet):

  • Return a byte array directly: instead, return an intermediate object to create that array from the library. Leave the conversion to image for a second step
  • Parallelize the execution

Add option to specify colors beforehand

This could be a list of color input controls with add / remove buttons. It might be nice to be able to specify exactly which color corresponds to which root, but that will not be very practical in most situations.

Generate a Expression<Func<>> from a string

This will ultimately be what gets evaluated for each pixel of the fractal. There are a few ways to parse arbitrary expressions out there, but probably none up for the task. Keep it in Expression<> form so that it can be derived later.

In fact, perhaps this should use an intermediate class structure like the original fractals application, with that class being responsible for the conversion to an Expression, or finding the derivative.

Add fractal presets

This will be a collection of settings (expression, multiplicity, options, etc.) that are known to produce nice fractals.

There should be a dropdown somewhere from where you pick one of those and all associated settings automatically change.

There are some settings that should probably not be loaded this way:

  • Image size
  • Colors

These could be put in a menu at the left side, similar to the one in the template. The menu could be used later for other things.

Add error handling for Azure Function call

The response from the function should probably not be the image contents directly. Instead, it should be a simple structure with a success / failure status, a reason for failure if any, and then the actual image contents. This implies there should be a generic try / catch block in the function.

Improve parallel execution in Azure

The parallelization works well locally because the number of cores is automatically set to those of the computer. However, this seems to be limited to 2 in Azure Functions.

The alternative should be to launch each parallel execution as a separate Azure Functions call. Before that, the way this gets parallelized should be improved as well, otherwise there would be 500 calls for a 500x500 image for example.

First step should be to increase the chunk size so that only one gets run per process. Rather than stripes, these should be random portions of the image, for example rectangles. The idea is to avoid the bottleneck of having to wait for a single function just because it received the chunks requiring the most iterations.

The fan-out / fan-in pattern for Durable Functions can be used for this.

The parallelization in MathUtils could be refactored into an abstract class to be passed as an argument to the fractal method. The current code would constitute one implementation of that class, and the future Azure version would be another.

Invert Y axis

Right now, the imaginary axis is positive downwards. Not too important for a visual-only app, but it gets counter-intuitive when specifying non-centered bounds.

Add README

Probably wait until there is a bit more to talk about.

Remember to include a status badge: CI/CD

Parallelize fractal generation

This will only be of benefit when calling the Azure Function for now. Ideas:

  • The image could be divided in stripes vertically or horizontally, with each core processing one of them
  • Option 1: only run in parallel the calls to the Newton method, then transform the solutions into an image in a single process
    • This should be simpler to implement, as there would be no need to synchronize anything between processes
  • Option 2: do the image transformation also in parallel
    • This is ideal, but the processes will need to synchronize the solutions reached and the colors used for those. To avoid race conditions where more than one process wants to add a solution simultaneously, it might become a bottleneck
    • Perhaps have a SemaphoreSlim that is only acquired when writing a new solution / color, at which point it is checked again whether the solution exists. When simply finding a solution in there, there would be no locking, and hence no important bottlenecks

Add string formatting

Apart from the obvious usefulness of being able to show the result to the user, this will also make easier to check whether the parsed expressions are correct in tests.

It could be a ToString() override with an optional overload that accepts a parameter for the variable (z by default).

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.