sclass rgbMakeGraph_Info { // input float overdrive = 1f; // output float min, max; public S toString() { ret "min: " + min + ", max: " + max; } } static RGBImage rgbMakeGraph(float[] data) { ret rgbMakeGraph(data, null); } static RGBImage rgbMakeGraph(float[] data, rgbMakeGraph_Info info) { if (empty(data)) ret new RGBImage(1, 1); float min = min(data), max = max(min+0.0001f, max(data)); if (info != null) { info.min = min; info.max = max; } int w = l(data), h = 60; RGBImage img = new RGBImage(w, h, Color.white); Color foreground = Color.red; for x to w: { float f = (data[x]-min)/(max-min); if (info != null) f *= info.overdrive; int y1 = max(0, iround(h*(1-f))); for (int y = y1; y < h; y++) img.setPixel(x, y, foreground); } ret img; }
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: | 575 / 575 |
Referenced in: | [show references] |