Guest User

Untitled

a guest
Nov 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // Synthesize color.
  2. color rndclr = color(random(255), random(255), random(255), random(255));
  3.  
  4. // Analyze color conveniently.
  5. float al = alpha(rndclr);
  6. float rd = red(rndclr);
  7. float gr = green(rndclr);
  8. float bl = blue(rndclr);
  9.  
  10. println("red\t" + rd);
  11. println("green\t" + gr);
  12. println("blue\t" + bl);
  13. println("alpha\t" + al);
  14.  
  15. // Re-Synthesize color conveniently.
  16. color recomposite = color(rd, gr, bl, al);
  17. println(hex(recomposite), hex(rndclr));
  18.  
  19. // Analyze color efficiently.
  20. al = rndclr >> 24 & 0xff;
  21. rd = rndclr >> 16 & 0xff;
  22. gr = rndclr >> 8 & 0xff;
  23. bl = rndclr & 0xff;
  24.  
  25. println("red\t" + rd);
  26. println("green\t" + gr);
  27. println("blue\t" + bl);
  28. println("alpha\t" + al);
  29.  
  30. // Re-synthesize color efficiently.
  31. recomposite = (int)al << 24 | (int)rd << 16 | (int)gr << 8 | (int)bl;
  32. println(hex(recomposite), hex(rndclr));
Add Comment
Please, Sign In to add comment