Skip to content

Instantly share code, notes, and snippets.

@golive
Created June 15, 2015 08:31
Show Gist options
  • Save golive/d3871398004e70699fa2 to your computer and use it in GitHub Desktop.
Save golive/d3871398004e70699fa2 to your computer and use it in GitHub Desktop.
Generate all colors of RGB in a png file
require 'chunky_png'
png = ChunkyPNG::Image.new(4096, 4096)
(0..255).each do |b|
(0..255).each do |g|
(0..255).each do |r|
x = b/16*256 + r
y = b%16*256 + g
png[x,y] = ChunkyPNG::Color.rgb(r, g, b)
end
end
end
png.save('color_palette.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment