Skip to content

Commit f8255b5

Browse files
committed
Sierpinski
1 parent 2fb668a commit f8255b5

File tree

3 files changed

+56
-56
lines changed

3 files changed

+56
-56
lines changed

examples/graph.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/sierpinski.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <math.h>
2+
#include <pluto.h>
3+
#include <stdlib.h>
4+
5+
typedef struct
6+
{
7+
float x, y;
8+
} point;
9+
10+
const int sx = 10; // Start X
11+
const int ex = 60; // End X
12+
const int ty = 10; // Top Y
13+
const int by = 90; // Extended bottom Y
14+
const int my = 90; // Extended max Y
15+
const int iter = 1000; // Iterations
16+
const int mid = sx + (ex - sx) / 2;
17+
18+
point vx[3] = { {sx, ty}, {ex, ty}, {mid, 0} };
19+
point init = {mid, 0};
20+
21+
void step()
22+
{
23+
int vt = rand() % 3;
24+
25+
init = (point){ init.x + (vx[vt].x - init.x) / 2,
26+
init.y + (vx[vt].y - init.y) / 2 };
27+
28+
pluto_set_pix(init.x, init.y);
29+
}
30+
31+
void animate()
32+
{
33+
for (int c = by; c < my; c++)
34+
{
35+
vx[2].y = c;
36+
init.y = (c - vx[0].y) / 2;
37+
38+
for (int i = 0; i < iter; i++)
39+
step();
40+
41+
pluto_write_out();
42+
pluto_render();
43+
pluto_clear_buffers();
44+
}
45+
}
46+
47+
int main()
48+
{
49+
pluto_init_window();
50+
51+
animate();
52+
53+
pluto_deinit();
54+
55+
return 0;
56+
}

examples/wall-density.c

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)