Skip to main content

Demo

Some scenarios when using Rust and Dart include:

  • Use arbitrary Rust libraries, in Dart: When there is a library only existing in Rust but not in Dart.
  • High-performance code in Rust, others in Dart: Rust makes it easy to write multi-thread code, algorithms, data-intensive operations, etc.
  • Logic in Rust, UI in Dart: When you want a UI framework (Flutter) for your Rust system.

Introduction

We demonstrate a simple example here. In this demo, let us draw a Mandelbrot set (a well-known infinite-resolution "image" generated by a simple math formula). The image is plotted in Flutter UI, generated by Rust algorithm, and communicated via this library. Tweak the number of threads to see how multi-thread Rust code speeds up :)

What is a Mandelbrot Set

The Mandelbrot set is the set of complex numbers c for which the function f_c(z)=z^{2}+c does not diverge to infinity when iterated from z=0. Images of the Mandelbrot set exhibit an elaborate and infinitely complicated boundary that reveals progressively ever-finer recursive detail at increasing magnifications.

Image credit: Simpsons contributor

Demo

Due to the limitation of GitHub Pages which hosts this documentation, this page will be auto refreshed once.

Loading...

All source code can be found in frb_example/gallery. Remember to ignore all ignore_me folders, which contain code unrelated to the purpose of the demos.

Remarks: The mandelbrot set was the only demo since 2021.10 in V1 version. The Rust code is deliberately not implemented the usual way, in order to ensure the computation speed is homogeneous for intuitive comparison.