Hue
# Hue is the color reflected from or transmitted through an object # and is typically referred to as the name of the color (red, blue, yellow, # etc.). Move the cursor vertically over each bar to alter its hue. require 'ostruct' attr_reader :bar_width, :color_array def setup size 640, 360 color_mode HSB, 360 no_stroke @bar_width = 20 @color_array = (0..width / bar_width).map do OpenStruct.new(hue: height, saturation: height, brightness: height) end end def draw color_array.each_with_index do |col, i| n = i * bar_width range = (n..n + bar_width) color_array[i].hue = mouse_y if range.include?(mouse_x) fill col.hue, col.saturation, col.brightness rect n, 0, bar_width, height end end
Saturation
# Saturation is the strength or purity of the color and represents the # amount of gray in proportion to the hue. A "saturated" color is pure # and an "unsaturated" color has a large percentage of gray. # Move the cursor vertically over each bar to alter its saturation. require 'ostruct' attr_reader :bar_width, :color_array def setup size 640, 360 color_mode HSB, 360 no_stroke @bar_width = 20 @color_array = (0..width / bar_width).map do |n| OpenStruct.new(hue: n * bar_width, saturation: height, brightness: height / 1.5) end end def draw color_array.each_with_index do |col, i| n = i * bar_width range = (n..n + bar_width) color_array[i].saturation = mouse_y if range.include? mouse_x fill col.hue, col.saturation, col.brightness rect n, 0, bar_width, height end end
Brightness
# Brightness is the relative lightness or darkness of a color. # Move the cursor vertically over each bar to alter its brightness. require 'ostruct' attr_reader :bar_width, :color_array def setup size 640, 360 no_stroke color_mode HSB, width, 100, height @bar_width = 20 @color_array = (0..width / bar_width).map do |n| OpenStruct.new(hue: n * bar_width, saturation: 100, brightness: height) end end def draw color_array.each_with_index do |col, i| n = i * bar_width range = (n..n + bar_width) color_array[i].brightness = mouse_y if range.include? mouse_x fill col.hue, col.saturation, col.brightness rect n, 0, bar_width, height end end
No comments:
Post a Comment