Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

15
LINES

< > BotCompany Repo | #1006086 // varyColor

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5548L/30K).

// TODO: does maxSteps 1 do anything?
static RGB varyColor(RGB rgb, int maxSteps default 25) {
  float max = maxSteps/255f;
  int s = random(3);
  if (s == 0)
    return new RGB(vary0to1(rgb.r, max), rgb.g, rgb.b);
  else if (s == 1)
    return new RGB(rgb.r, vary0to1(rgb.g, max), rgb.b);
  else
    return new RGB(rgb.r, rgb.g, vary0to1(rgb.b, max));
}

static Color varyColor(Color color, int maxSteps default 25) {
  ret toColor(varyColor(RGB(color), maxSteps);
}

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: #1006086
Snippet name: varyColor
Eternal ID of this version: #1006086/4
Text MD5: 0136d0682533075ac20caef9633f66f2
Transpilation MD5: 7f27f9c0b2f9797270ca456996755d8f
Author: stefan
Category: javax / genetic optimization
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-13 05:27:54
Source code size: 481 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 586 / 677
Version history: 3 change(s)
Referenced in: [show references]