Skip to content

Commit

Permalink
🎉 Added saturation and lightness parameters
Browse files Browse the repository at this point in the history
🎉 Added saturation and lightness parameters to ColorRange feature
  • Loading branch information
LucasWolfgang committed Apr 17, 2022
1 parent f354745 commit 6363528
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Gist Parameter | Description
`maxColorRange` | Maximum value in the range used to define the message color.
`minColorRange` | Minimum value in the range used to define the message color.
`invertColorRange` | If the range should be inverted, causing a smaller value to have green color.
`colorRangeSaturation` | Saturation used by the color range feature. Defaults to 100%.
`colorRangeLightness` | Lightness used by the color range feature. Defaults to 40%.

### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)

Expand Down
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ try {
const minColorRange = core.getInput('minColorRange');
const maxColorRange = core.getInput('maxColorRange');
const invertColorRange = core.getInput('invertColorRange');
const colorRangeSaturation = core.getInput('colorRangeSaturation');
const colorRangeLightness = core.getInput('colorRangeLightness');

if (labelColor != '') {
content.labelColor = labelColor;
Expand All @@ -39,13 +41,21 @@ try {
const val = parseFloat(valColorRange);
if (val < min) val = min;
if (val > max) val = max;
let hue = 0
let hue = 0;
if (invertColorRange == '') {
hue = Math.floor((val - min) / (max - min) * 120);
} else {
hue = Math.floor((max - val) / (max - min) * 120);
}
content.color = "hsl(" + hue + ", 100%, 40%)";
let sat = 100;
if(colorRangeSaturation != '') {
sat = colorRangeSaturation;
}
let lig = 40;
if(colorRangeLightness != '') {
lig = colorRangeLightness;
}
content.color = "hsl(" + hue + ", " + sat + "%, " + lig + "%)";
} else if (color != '') {
content.color = color;
}
Expand Down

0 comments on commit 6363528

Please sign in to comment.