MatthewPeterKelly / MatthewPeterKelly/fractal-renderer

Serpinsky Triangle via Line Drawing

Open
#44 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle

Chaos Game:

The "chaos game" algorithm for generating the fractal is very similar to the type of process that was used for the Barnsley fern fractal #39.

Continuous Line / Koch Snowflake-Style

Might be worth implementing with some other algorithm too. The me with a continuous line was neat, and would make an awesome animation...

Simple Recursive Algorithm:

I think the simplest (and fastest) implementation would just be something like this:

  • draw outer triangle boundary as lines
  • start recursion:
    • draw upside-down inner triangle as lines
    • recurse into each of the three corner triangles
    • iterate until pixel distance between the bottom corners of the triangle is ~3 pixels
      • this can be precomputed into a fixed recursion depth

To implement this, we'll need line drawing. Luckily, there is a crate for that, built on the image crate that we're already using. Here is the exact method call that I think we would want to use:
https://docs.rs/imageproc/latest/imageproc/drawing/fn.draw_antialiased_line_segment_mut.html

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Barnsley fern fractal implementation referenced as issue #39 and the project's current use of the Rust image crate. Then evaluate imageproc's draw_antialiased_line_segment_mut for the outer and recursive triangle lines. Done means rendering a Sierpiński triangle recursively until the triangle's bottom corners are about 3 pixels apart.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.