Skip to content

Commit 8e2e82c

Browse files
authored
Merge pull request #333 from alecmolloy/rgb+rgba
Adding rgb+rgba color functions for straightforward color creation
2 parents 98722a3 + f99da23 commit 8e2e82c

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/language/modules/colors.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,31 @@ function rotate(color, amount) {
136136
return Color(color).rotate(amount).rgbaString();
137137
}
138138

139+
/*
140+
* Rotate color hue by given amount
141+
*
142+
* @param {Number} red
143+
* @param {Number} green
144+
* @param {Number} blue
145+
* @return {String}
146+
*/
147+
function rgb(red, green, blue) {
148+
return "rgb(" + red + ", " + green + ", " + blue + ")";
149+
}
150+
151+
/*
152+
* Rotate alpha color hue by given amount
153+
*
154+
* @param {Number} red
155+
* @param {Number} green
156+
* @param {Number} blue
157+
* @param {Number} alpha
158+
* @return {String}
159+
*/
160+
function rgba(red, green, blue, alpha) {
161+
return "rgba(" + red + ", " + green + ", " + blue + ", " + alpha + ")";
162+
}
163+
139164
/*
140165
* Get color opacity or set it to value if it's passed
141166
*
@@ -233,9 +258,11 @@ module.exports = {
233258
hue : hue,
234259
setTransparency : setTransparency,
235260
rotate : rotate,
261+
rgb : rgb,
262+
rgba : rgba,
236263
opacity : opacity,
237264
opacize : opacize,
238265
transparentize : transparentize,
239266
setBrightness : setBrightness,
240267
setSaturation : setSaturation
241-
};
268+
};

lib/language/modules/palette.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
"steelblue" : "#4682B4",
138138
"tan" : "#D2B48C",
139139
"teal" : "#008080",
140+
"transparent" : "rgba(0,0,0,0)",
140141
"thistle" : "#D8BFD8",
141142
"tomato" : "#FF6347",
142143
"turquoise" : "#40E0D0",

0 commit comments

Comments
 (0)