Skip to content

Instantly share code, notes, and snippets.

@Demonstrandum
Last active June 23, 2017 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demonstrandum/45c21211323fb55b23948e72530bb36d to your computer and use it in GitHub Desktop.
Save Demonstrandum/45c21211323fb55b23948e72530bb36d to your computer and use it in GitHub Desktop.
StumpyCore/PNG form_hsl function example:
require "stumpy_png"
include StumpyPNG
width = 361
height = 101
spectrum = Canvas.new(width, height)
(0..width - 1).each do |x|
(0..height - 1).each do |y|
# RGBA.from_hsla_n(hue, saturation, lightness, alpha) is an internal helper method
color = RGBA.from_hsl([x, 64, y]) # Here from_hsl(x, 100, y) would work exactly the same
spectrum[x, y] = color
end
end
StumpyPNG.write(spectrum, "spectrum.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment