kixe Posted September 8, 2018 Author Share Posted September 8, 2018 @adrian Thanks for pointing on this. I added a fallback to the standard dechex() function for 64-bit systems. In the rare case that neither the BCMath extension is installed nor the system can handle 64-bit integers, the module is not installable. 1 Link to comment Share on other sites More sharing options...
adrian Posted September 8, 2018 Share Posted September 8, 2018 Thanks @kixe One more request for you please. I am using this setup: $('#{id}').on('keyup', function() { $(this).css({'background-color' : $(this).val()}); $(this).css({'color' : ($(this).val().replace('#','0x')) > (0xffffff/2) ? '#333' : '#fff'}); }); so that the input background changed dynamically as the hex code changes, but I also want the background to be colored onload so I changed case 4 to this: case 4: $this->attr('style', "color: $textColor; background: $bgColor;"); if ($this->alpha) $this->attr('value', $color32); else $this->attr('value', $color24); break; I guess I could probably modify the JS code to do the onload as well, but I was wondering if you thought such a setup would be a worthwhile core option? 1 Link to comment Share on other sites More sharing options...
adrian Posted September 8, 2018 Share Posted September 8, 2018 Another nice option might be to extend spectrum to do this. I just did this via browser dev tools, but I expect it could be done with JS quite easily if we has the option to inject JS when using the Inputfield with Spectrum Color Picker (JavaScript) option. I really like being able to see the hex code without having to open the picker. What do you think? Link to comment Share on other sites More sharing options...
kixe Posted September 8, 2018 Author Share Posted September 8, 2018 2 hours ago, adrian said: What do you think? As you know I tested the module with several different javascript based color pickers via the included custom script option. I will leave this as is. Use and modify the picker you like. Another thing is the dynamically change of the input and background color in the Textfield. This is pretty good and if I find time I will implement this. 1 Link to comment Share on other sites More sharing options...
tpr Posted September 8, 2018 Share Posted September 8, 2018 Offtopic: if I will have some time I will add a similar feature to aos. The reason I haven't done this already is that never had the need for a color picker in the admin. This is the js I plan to use: https://github.com/narsenico/a-color-picker 3 Link to comment Share on other sites More sharing options...
slave Posted October 29, 2018 Share Posted October 29, 2018 I use these settings 'rgba(68, 100, 221, 0.98)' But the issue looks like this (render)rgba(234, 25, 25, 0,93)but I need it so rgba(234, 25, 25, 0.93) what am I doing wrong 1 Link to comment Share on other sites More sharing options...
kixe Posted January 12, 2019 Author Share Posted January 12, 2019 On 10/29/2018 at 4:28 PM, slave said: what am I doing wrong Nothing 🙂 I fixed this. Update to 1.0.9 2 Link to comment Share on other sites More sharing options...
slave Posted January 12, 2019 Share Posted January 12, 2019 15 hours ago, kixe said: Nothing 🙂 I fixed this. Update to 1.0.9 I have a new problem Mr. rgba(0, 56, 119, 1.)but I need it so rgba(0, 56, 119, 1) or rgba(0, 56, 119, 1.0) Blease update Link to comment Share on other sites More sharing options...
kixe Posted October 17, 2019 Author Share Posted October 17, 2019 On 1/12/2019 at 5:42 PM, slave said: I have a new problem Mr. rgba(0, 56, 119, 1.)but I need it so rgba(0, 56, 119, 1) or rgba(0, 56, 119, 1.0) Everything fixed. Current module version 1.1.3 Link to comment Share on other sites More sharing options...
JFn Posted January 11, 2020 Share Posted January 11, 2020 I ran into a specific multilanguage problem. When setting the default language C parameter of LanguageSupport to nl_NL.UTF-8 (or nl_BE.UTF-8), then the Color module hsl return value has a comma as decimal separator, which is not a valid CSS value (or a valid hsl value for that matter). Example with dutch locale: hsl(195, 96,2%, 59%); Should always be: hsl(195, 96.2%, 59%); no matter the chosen locale. (note: the comma is the expected/normal decimal separator in dutch, so it's not a LanguageSupport mistake) 1 Link to comment Share on other sites More sharing options...
kixe Posted March 21, 2020 Author Share Posted March 21, 2020 On 1/11/2020 at 3:00 PM, JFn said: Example with dutch locale: hsl(195, 96,2%, 59%); Should always be: hsl(195, 96.2%, 59%); no matter the chosen locale. This bug is fixed now. Current module version 1.1.4 1 Link to comment Share on other sites More sharing options...
Hurme Posted May 4, 2020 Share Posted May 4, 2020 I'm running into an error using the 1.1.4. version. In field input settings: Inputfield type = "text" and value type = 8 digits. In actual page where I'm using this: If I try to use #ff000000 I get HTML 5 field error stating "Please match the format requested" and saving the page fails. If I try to use #000000 I get "InputfieldColor: Does not match required pattern: /#?[a-fA-F\d]{8}/" So something is stopping me from using it with alphavalues. If I go back to using 6 digit hex value it works fine. EDIT: It would be awesome if I could use RGBA(0,0,0,0) as input value as well. Using the hex value I'll have to google the value each time instead of just typing it out. Another great thing would be, if I could choose "empty" as default value. The forced #000000 may not print anything, but looks very confusing because it looks like someone has typed a value in the field. Link to comment Share on other sites More sharing options...
kixe Posted May 15, 2020 Author Share Posted May 15, 2020 @Hurme On 5/4/2020 at 1:10 PM, Hurme said: If I try to use #ff000000 I get HTML 5 field error stating "Please match the format requested" and saving the page fails. If I try to use #000000 I get "InputfieldColor: Does not match required pattern: /#?[a-fA-F\d]{8}/" This looks like you have choosen the wrong input type: On 5/4/2020 at 1:10 PM, Hurme said: EDIT: It would be awesome if I could use RGBA(0,0,0,0) as input value as well. For your needs please use SpectrumColorPicker as Input and add the following code showAlpha: true, showInput: true in the color picker options field. This setup will provide something like: Link to comment Share on other sites More sharing options...
kixe Posted May 15, 2020 Author Share Posted May 15, 2020 I have added Fieldtype Select Color Options to the package. Read more here: Link to comment Share on other sites More sharing options...
kixe Posted October 10, 2021 Author Share Posted October 10, 2021 Added some useful functions to FieldtypeColor class: /** * Find the "naive" difference between two colors. * @param int[] $color_a Three-element array with R,G,B color values 0-255. * @param int[] $color_b Three-element array with R,G,B color values 0-255. * @return int */ public function getColorDistance(array $color_a, array $color_b) /** * Find the difference between two colors' luminance values. * @param int[] $color_a Three-element array with R,G,B color values 0-255. * @param int[] $color_b Three-element array with R,G,B color values 0-255. * @return int */ public function getLuminanceDistance(array $color_a, array $color_b) /** * Find the closest named color * @param hexcolor 6 or 8 digits, with or without leading '#' * @return string */ public function getClosestColorName(string $color) Usage example: $fc = $modules->get('FieldtypeColor'); $colorname = $fc->getClosestColorName('#01fb99'); var_dump($colorname); // string(17) "MediumSpringGreen" I needed this for the COLOR property in .ics file type. According to the specifications, the value must be a valid CSS3 color name. https://icalendar.org/New-Properties-for-iCalendar-RFC-7986/5-9-color-property.html 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now