← Back to context

Comment by ajkjk

2 years ago

Pretty impressive. I was curious how they made the whole thing so I went to look at the source for the images. It's mostly in one 10000 line JS file which draws all the graphics onto <canvas> in JS, plus a bunch of WebGL that goes over my head. The code looks like

    function draw_car(ctx, rot) {
    ctx.save();
    let sc = 0.04;
    ctx.scale(sc, -sc);
    ctx.lineWidth \*= 1 / sc;
    ctx.translate(-286, -51);
    ctx.beginPath();
    ctx.moveTo(463.93652, 9.89137);
    ctx.bezierCurveTo(462.12793, 6.72347, 461.22363, 3.5344, 461.22363, 0.32417);
    ctx.bezierCurveTo(447.58911, -1.16177, 434.20691, 2.81333, 434.85754, 5.10777);
    ...

I wonder what their workflow was. Surely all those curves weren't programmed by hand?

Not sure what you are looking at but https://ciechanow.ski/js/airfoil.js is the JS that contains the code for the graphics/visuals. And it is completely readable.

The 2d part though is probably generated.

Just a small note, that code looks like Context2d rather than WebGL unless you were looking at something else in the code