I took a crack at this, patch attached.

This might be useful to others who use gradient opacity along with gradient coloring in their themes and wants them to also be adjustable through the color module.

Not being a color expert I don't know if there is more complicated algorithms needed to incorporate gradient opacity when shifting colors so keep that in mind. I took the simple approach of just converting the color portion of css rgba to css hex notation, then letting the color module do its normal shifting on that number, and then incorporating the resultant css hex value back into the css rgba string.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Reg’s picture

Version: 7.x-dev » 8.x-dev

Just found out that things are being done in Drupal 8.x and then getting back ported now.

joachim’s picture

Status: Active » Needs work

I'm not quite sure what this does -- does it allow opacity to be controlled in the UI, or just preserve it if themes set it in their colour options?

A few code style points below:

+++ b/www/cms/modules/color/color.module
@@ -738,3 +745,46 @@ function _color_rgb2hsl($rgb) {
+ * Create a css hex string from a css rgba string

Needs a full stop; parameters and return should be described.

+++ b/www/cms/modules/color/color.module
@@ -738,3 +745,46 @@ function _color_rgb2hsl($rgb) {
+  preg_match($re,	$rgba, $rgb);

Funny whitespace here.

14 days to next Drupal core point release.

Reg’s picture

Looks like I got a tab in there where there should have been a space, just remove it. I can't really rebuild the patch because I have other changes in the module now so the resultant patch wouldn't make sense.

What the code does is allow the color module to make shifts on CSS like this:

.something div {
  /* Horizontal */
  background: -moz-linear-gradient(left,  rgba(31,30,31,1) 0%, rgba(34,35,34,0) 5%, rgba(34,35,34,0) 95%, rgba(31,30,31,1) 100%); /* FF3.6+ */
  background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(31,30,31,1)), color-stop(5%, rgba(34,35,34,0)), color-stop(95%, rgba(34,35,34,0)), color-stop(100%, rgba(31,30,31,1))); /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(left,  rgba(31,30,31,1) 0%, rgba(34,35,34,0) 5%, rgba(34,35,34,0) 95%, rgba(31,30,31,1) 100%); /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(left,  rgba(31,30,31,1) 0%, rgba(34,35,34,0) 5%, rgba(34,35,34,0) 95%, rgba(31,30,31,1) 100%); /* Opera 11.10+ */
  background: -ms-linear-gradient(left,  rgba(31,30,31,1) 0%, rgba(34,35,34,0) 5%, rgba(34,35,34,0) 95%, rgba(31,30,31,1) 100%); /* IE10+ */
  background: linear-gradient(left,  rgba(31,30,31,1) 0%, rgba(34,35,34,0) 5%, rgba(34,35,34,0) 95%, rgba(31,30,31,1) 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1f1e1f', endColorstr='#1f1e1f',GradientType=1 ); /* IE6-9 */
  filter: progid:DXImageTransform.Microsoft.alpha(opacity=0); /* IE6-9 */
  /* We don't put anything after this filter statement since it's not valid css and therefore will invalidate a following statement */
}

As you can see with gradients that have opacity as well you have this "rgba" format for the color. With this extra bit of code the module will shift that as well as the standard "#012345" format for representing color.

RunePhilosof’s picture

Status: Needs work » Needs review
FileSize
2.77 KB

Fixed some errors in the regex and made a diff against 8.x.
Also added some comments.

RunePhilosof’s picture

A port for Drupal 7.x.

markhalliwell’s picture

#4: color-support_rgba-1392528-4.patch queued for re-testing.

markhalliwell’s picture

If we're going to do this, I (personally) would like a way to support also changing the opacity. I could be persuaded either way on this.

_12345678912345678’s picture

#4: color-support_rgba-1392528-4.patch queued for re-testing.

_12345678912345678’s picture

Retested and it passed :)

Jeff Burnz’s picture

Oh good lord, if this gets in I'll be a kid in a lolly shop, really, fantastic.

Reg’s picture

Guys, I'm not sure if it's worth working on this. We could probably depreciate this thread because I put this patch along with a few others I made to the color module all into one patch which other people have been keeping up to date for D8. The combined patch is over here: https://drupal.org/node/1763040 .

Sorry for the upset, I should have notice earlier.

mgifford’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)
Related issues: +#1763040: Accumulative patch of fixes and enhancements