blob: 945909f67045cf602448b54aaa2dc203d068ccf8 (
plain) (
blame)
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
|
#include "web_opts.h"
#include "comp.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <emscripten/emscripten.h>
int delay_ms = 1000;
void opts_init()
{
EM_ASM(readOpts());
char buf[64];
sprintf(buf, "%d", delay_ms);
EM_ASM({elemSetValue($0, $1)}, "#delay", buf);
int len = sprintf(buf, "%4.2f", horizontal_stdev);
char *dot = strchr(buf, '.');
if (dot) {
for (char *ptr = buf + len - 1; ptr >= dot; --ptr) {
if (*ptr != '0' && *ptr != '.')
break;
*ptr = 0;
}
}
EM_ASM({elemSetValue($0, $1)}, "#stdev", buf);
}
EMSCRIPTEN_KEEPALIVE
void set_delay(int delay)
{
delay_ms = delay;
}
EMSCRIPTEN_KEEPALIVE
void set_stdev(float stdev)
{
if (!isnan(stdev))
horizontal_stdev = vertical_stdev = stdev;
}
|