-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReloadableFunction.cpp
More file actions
52 lines (41 loc) · 1.12 KB
/
ReloadableFunction.cpp
File metadata and controls
52 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include "ReloadableFunction.h"
IMPL_RELOADABLE_FUNCTION(int, DrawAscii, int width, int height)
{
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
/*
Feel free to comment, uncomment and modify any of
the following blocks of code while the program is running.
Recompile with:
g++ -DHOT_RELOAD -shared ReloadableFunction.cpp -o DrawAscii.dll
The function will automatically be hot reloaded.
*/
// Get coordinates from the center of the drawable area
int cX = x - (width / 2);
int cY = y - (height / 2);
// Draw a circle
if ((cX * cX + cY * cY) < 27)
printf("@");
// Draw a rhombus
// int absX = cX > 0 ? cX : -cX;
// int absY = cY > 0 ? cY : -cY;
// if ((absX + absY) < 6)
// printf("@");
// Border
else if ((x == 0) || (y == 0) || (x == width - 1) || (y == height - 1))
printf("#");
// Empty space
else
printf(" ");
}
printf("\n");
}
// Return the number of times that this function has been called
// This counter resets when the function is reloaded
static int counter = 0;
counter++;
return counter;
}