Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LED Feature Request: generate frames to interpolate between colors. #176

Open
clintiepoo opened this issue Jun 11, 2020 · 0 comments
Open

Comments

@clintiepoo
Copy link

@haata - here's the script I wrote FYI. It linear interpolates between the colors based on the number of steps and outputs full-keyboard frames.

import numpy as np
from scipy.interpolate import interp1d    

colors = [[105,255,105]] # White
colors.append([0,0,0]) # Dark
colors.append([255,0,0]) # Red
colors.append([255,60,0]) # Orange
colors.append([255,255,0]) # Yellow
colors.append([0,255,0]) # Green
colors.append([135,135,0]) # Light Blue
colors.append([0,0,255]) # Dark Blue
colors.append([90,0,255]) # Purple

colors.append(colors[0]) # first color again - makes a loop

#Steps between color
steps = 100

# Decompose lists into individual color lists
reds = [item[0] for item in colors]
greens = [item[1] for item in colors]
blues = [item[2] for item in colors]

# X axis = array from 0 to number of colors
x = np.arange(0,len(colors))

# Interpolate Functions
f_red = interp1d(x,reds)
f_green = interp1d(x,greens)
f_blue = interp1d(x,blues)

# Generate final x values
step=1/(steps+1)
x_fin = np.arange(0,len(colors)+step-1,step)

# Write to file (overwrite)
f = open("output.txt", "w")

for x in x_fin:
    red = int(f_red(x))
    green = int(f_green(x))
    blue = int(f_blue(x))
    f.write("P[c:0%%](%s,%s,%s),P[c:100%%](%s,%s,%s);\r" % (red,green,blue,red,green,blue))

f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant