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

5
LINES

< > BotCompany Repo | #1034418 // colorPaletteByBits (bits per RGB channel, so 1 through 8)

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

Libraryless. Click here for Pure Java version (13740L/77K).

static L<Color> colorPaletteByBits(int bits) {
  ret map(outerProduct(rep(3,
    countIteratorAsList(0, 1 << bits, i -> iround(i*255.0/(1 << bits-1))
    ))), rgb -> new Color(first(rgb), second(rgb), third(rgb)));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034418
Snippet name: colorPaletteByBits (bits per RGB channel, so 1 through 8)
Eternal ID of this version: #1034418/4
Text MD5: ea93037abf690f1c4598d742f59f7e0b
Transpilation MD5: 05fcb3c2b9e26facf4986e3fea2112a9
Author: stefan
Category: javax / colors
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-07 00:37:45
Source code size: 220 bytes / 5 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 258
Version history: 3 change(s)
Referenced in: [show references]