Skip to content

Commit

Permalink
finalized new color palettes, static white pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jackw01 committed Dec 28, 2021
1 parent de64fd2 commit ee43957
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 38 deletions.
13 changes: 11 additions & 2 deletions ledcontrol/animationpatterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def blank(t, dt, x, y, prev_state):
return (0, 0, 0), ColorMode.hsv

static_patterns = [0, 1] # pattern IDs that display a solid color
static_patterns = [0, 1, 2] # pattern IDs that display a solid color

default = {
0: {
Expand All @@ -28,6 +28,15 @@ def pattern(t, dt, x, y, z, prev_state):
'''
},
1: {
'name': 'Static White',
'primary_speed': 0.0,
'primary_scale': 1.0,
'source': '''
def pattern(t, dt, x, y, z, prev_state):
return (0, 0, 1), hsv
'''
},
2: {
'name': 'Static Gradient 1D',
'primary_speed': 0.0,
'primary_scale': 1.0,
Expand All @@ -36,7 +45,7 @@ def pattern(t, dt, x, y, z, prev_state):
return palette(x), hsv
'''
},
2: {
3: {
'name': 'Static Gradient Mirrored 1D',
'primary_speed': 0.0,
'primary_scale': 1.0,
Expand Down
35 changes: 2 additions & 33 deletions ledcontrol/colorpalettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,6 @@
]
],
},
60: {
'name': 'Tropical',
'mode': 0,
'colors': [
[
0.8091639350442326,
1,
1
],
[
0.7397193908691406,
0.9472211085328268,
1
],
[
0.07063562729779412,
0.23162477825759747,
1
],
[
0.09412428911994487,
1,
1
],
[
0.05739369111902574,
1,
1
]
],
},
70: {
'name': 'Viridis',
'mode': 0,
Expand Down Expand Up @@ -398,8 +367,8 @@
1
],
[
0.9542738970588235,
0.32107431954200116,
0.5804735071518842,
0.24538624614750573,
1
]
],
Expand Down
11 changes: 8 additions & 3 deletions ledcontrol/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ function updatePaletteColorBar() {
f = f % sectorSize / sectorSize;
const c1 = palette.colors[sector];
const c2 = palette.colors[sector + 1];
const h1 = c2[0] - c1[0];
const h2 = c2[0] - 1 - c1[0];
const h = (f * (Math.abs(h1) < Math.abs(h2) || h1 === 1 ? h1 : h2) + c1[0]) * 360;
let h1 = c2[0] - c1[0];
// Allow full spectrum if extremes are 0 and 1 in any order
// otherwise pick shortest path between colors
if (Math.abs(h1) != 1) {
if (h1 < -0.5) h1++;
if (h1 > 0.5) h1--;
}
const h = (f * h1 + c1[0]) * 360;
const s = (f * (c2[1] - c1[1]) + c1[1]) * 100;
const v = (f * (c2[2] - c1[2]) + c1[2]) * 100;
const l = (2 - s / 100) * v / 2;
Expand Down

0 comments on commit ee43957

Please sign in to comment.