1 | sclass rgbMakeGraph_Info {
|
2 | // input |
3 | float overdrive = 1f; |
4 | |
5 | // output |
6 | float min, max; |
7 | |
8 | public S toString() {
|
9 | ret "min: " + min + ", max: " + max; |
10 | } |
11 | } |
12 | |
13 | static RGBImage rgbMakeGraph(float[] data) {
|
14 | ret rgbMakeGraph(data, null); |
15 | } |
16 | |
17 | static RGBImage rgbMakeGraph(float[] data, rgbMakeGraph_Info info) {
|
18 | if (empty(data)) ret new RGBImage(1, 1); |
19 | float min = min(data), max = max(min+0.0001f, max(data)); |
20 | if (info != null) {
|
21 | info.min = min; |
22 | info.max = max; |
23 | } |
24 | int w = l(data), h = 60; |
25 | RGBImage img = new RGBImage(w, h, Color.white); |
26 | Color foreground = Color.red; |
27 | for x to w: {
|
28 | float f = (data[x]-min)/(max-min); |
29 | if (info != null) f *= info.overdrive; |
30 | int y1 = max(0, iround(h*(1-f))); |
31 | for (int y = y1; y < h; y++) |
32 | img.setPixel(x, y, foreground); |
33 | } |
34 | ret img; |
35 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1006365 |
| Snippet name: | rgbMakeGraph |
| Eternal ID of this version: | #1006365/1 |
| Text MD5: | bdc85dc1260d1b6a0350751ac8d9427a |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-12-29 22:16:24 |
| Source code size: | 854 bytes / 35 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 808 / 820 |
| Referenced in: | [show references] |