Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

Relentlessly Gay™

Each method takes in a set of hue lights and an option set of other parameters for desired visual effect.

Basic setup

Optionally set export HUE_USERNAME=3N70R9-kFFVm-L2GvVOOEpXdDV6Th4yCUsdLrmcb if you know your username already. Otherwise you have to go click the sync button.

require 'hue'
require_relative "./hue_pride.rb"
client = Hue::Client.new
lights = client.lights
10.times { rainbow_marquee(lights, offset:0, delay: 0.8, rotations: 1) }

Ta da.

RED = [0.6679, 0.3181]
ORANGE = [0.55, 0.4]
YELLOW = [0.5425, 0.4196]
GREEN = [0.41, 0.51721]
BLUE = [0.1691, 0.0441]
VIOLET = [0.4149, 0.1776]
COLORS = [RED, ORANGE, GREEN, BLUE, VIOLET]
def rainbow(lights, offset: 0, delay: 0)
lights.each.with_index do |l, i|
l.set_state xy: COLORS[(i+offset) % COLORS.length]
sleep delay
end
end
def rainbow_marquee(lights, offset: 0, delay: 0, rotations: 1)
(rotations*(COLORS.length)).times do |j|
rainbow(lights, offset: j)
sleep delay
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment