Advertisement
iSach

Progressive RGB rainbow changment algorithm. (basics)

Oct 26th, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. private int r = 255; // Default color to red.
  2. private int g = 0;
  3. private int b = 0;
  4.  
  5. private void nextRGB() {
  6. if (r == 255 && g < 255 && b == 0)
  7. g += 15;
  8. if (g == 255 && r > 0 && b == 0)
  9. r -= 15;
  10. if (g == 255 && b < 255 && r == 0)
  11. b += 15;
  12. if (b == 255 && g > 0 && r == 0)
  13. g -= 15;
  14. if (b == 255 && r < 255 && g == 0)
  15. r += 15;
  16. if (r == 255 && b > 0 && g == 0)
  17. b -= 15;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement