Advertisement
here2share

# equal_spaced_colors.py

Aug 12th, 2024
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. # equal_spaced_colors.py
  2.  
  3. num_steps = 100
  4. step_size = (256**3) // (num_steps - 1)
  5.  
  6. def convert_int_to_rgb(value):
  7.     b = value % 256
  8.     value //= 256
  9.     g = value % 256
  10.     value //= 256
  11.     r = value % 256
  12.     return (r, g, b)
  13.  
  14. rgb_values = []
  15.  
  16. steps = 0
  17. while len(rgb_values) < num_steps:
  18.     rgb_values.append(convert_int_to_rgb(steps))
  19.     steps += step_size
  20. rgb_values[-1] = (255, 255, 255)
  21.  
  22. print(rgb_values)
  23. print(len(rgb_values))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement