ctgreybeard

Progressive RGB rainbow changment algorithm. (basics)

Aug 21st, 2022
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | Source Code | 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.     }
Tags: Rainbow
Add Comment
Please, Sign In to add comment