Last active
June 23, 2017 18:22
-
-
Save Demonstrandum/45c21211323fb55b23948e72530bb36d to your computer and use it in GitHub Desktop.
StumpyCore/PNG form_hsl function example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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