magicbottle

now an anji main and 水月の運び-ing away

  • they/them
Bench 1RM58 kg
Squat 1RM85 kg
Deadlift 1RM105 kg
ClimbingNewb
ProgrammingC, Rust, Python
CSS Crimes?Sometimes
Gender?Sometimes
Affection?Affectionate
DiscordMagicBottle#9930

if you haven't done it before it's very cool, the main loop only requires additions and comparisons once set up with the right constants. something like

for y in y_min..y_max {
    let start_e0 = e0;
    let start_e1 = e1;
    let start_e2 = e2;
    for x in x_min..x_max {
        let inside =  e0 > 0. && e1 > 0. && e2 > 0.;
        let color = if inside { GREEN } else { RED };
        draw_circle((x * 10) as f32, (y * 10) as f32, 3.0, color);
        e0 += dy0;
        e1 += dy1;
        e2 += dy2;
    }
    e0 = start_e0;
    e1 = start_e1;
    e2 = start_e2;
    e0 -= dx0; // y is down!
    e1 -= dx1;
    e2 -= dx2;
}
syntax highlighting by codehost

(ignoring the fact that i'm multiplying for my visualization)

if you want to learn where those constants came from and how they work you can read A Parallel Algorithm for Polygon Rendering by Pineda. This part of A Trip through the Graphics Pipeline has also been helpful though a bit obtuse without the paper.


You must log in to comment.