Skip to content

๐Ÿ“š Use the p5.js JavaScript library -- from C!

License

Notifications You must be signed in to change notification settings

alextyner/p5.js-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

p5.js-c

Use the p5.js JavaScript library -- from C!

Why?

Just in case you ever wanted to write this

#include "p5.h"

#define WIDTH 400
#define HEIGHT 400

p5_SETUP(
    createCanvas(WIDTH, HEIGHT);
    background(0);
);

FUNCTION(void, draw_surprised_face, (int x, int y), 
    noFill();
    stroke(255);
    circle(x, y, 80); // Head outline.
    fill(255);
    circle(x - 20, y - 10, 10); // Left eye.
    circle(x + 20, y - 10, 10); // Right eye.
    ellipse(x, y + 10, 30, 10); // Mouth.
);

int main(int argc, char **argv) {
    draw_surprised_face(WIDTH / 2, HEIGHT / 2);
    return 0;
}

and then compile it

$ make
emcc -Wall --shell-file template.html *.c -o dist-web/index.html

to produce this:

surprised face canvas

About

๐Ÿ“š Use the p5.js JavaScript library -- from C!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published