HTML5 Color Picker - color not changed - color-picker

I've noticed a strange behavior with the color picker. When I pick any color from the basic colors (predefined colors), the button's color (the one of the html input element) is changed accordingly.
However, when picking any other color from the the gradient color picker, the button's color won't change. It will stay white. (Note: Don't pick a basic color first or refresh the jsbin page first if you're going to test it)
But... when I first pick a basic color and press OK and then pick a color from the gradient color picker, the button's color will change.
(Tested with Chrome 69)
Video (gif):
https://giphy.com/gifs/8vCEY7uyz8m17N0bkz
Test it:
http://output.jsbin.com/ivAhORu/1
var i = 0;
var inp=document.createElement("input");
inp.type = 'color';
inp.id = 'colo_'+i;
inp.value = '#ffffff';
inp.className = 'datafield';
document.body.appendChild(inp);

It's not actually an error, when you set a color picker to pure white or pure black the luminosity is adjusted to give you the desired color. When you pick a swatch the luminosity is changed to that swatch so it seems like it wasn't working before, but in fact it was working and if you adjusted the luminosity you'd see the color change correctly. You might want to consider a different starting color other than pure black or pure white.

Related

How to control the smart light (color , color tempreature, brightness)

If the light is set to Red, and I want to modify the brightness.
But the Color Model(rgb or hsb) isn't support the brightness.same with color tempreature.
What should I do? Need to change to White light Model, then adjust the brightness?
So, you want to change the color and brightness both. If that is what you want to do then you have to implement two separate variables for brightness and color. The brightness cannot be controlled using just rgb or hsv, it uses separate variable and it ranges from 0-100.
Go through this:-
https://developers.google.com/actions/smarthome/traits/colorsetting

Unity built in colour picker

I am using Unity 2017 and I noticed that when I open the colour picker the color values appears in HSV values and not RGB.
On my second PC, the colour values are on RGB.
I have tried to look online how to change it, but Google doesn't seems to understand me and all the results are how to convert HSV to RGB in code.
All I want to do is set the built-in colour picker values to RGB
Thanks in advance
Inside the Image component just above the colour sliders there is a small icon showing 3 colour bars (a coloured one, and two black/white bars), clicking on this will swap between HSV/RGB values
It looks like this
In Unity 2019(alpha) they made it way clearer. If you click on the colour picker there will be a dropdown menu (located inbetween the colour wheel and colour sliders) with three options: HSV, RGB (0 - 1.0) and RGB (0 - 255)

Is there a way to change a UITextField's cursor color other than .tintColor?

Basically, my goal is to have UISearchBarIcon.search be one color, and the cursor color be another. Since I have a dark and a light theme in my app I'm using alwaysTemplate for the UIImage for the search icon.
Found something about using this:
(textFieldInsideSearchBar?.value(forKey: "textInputTraits") as! String)["insertionPointColor"] = UIColor.red
But that doesn't seem to be valid as I get "Cannot subscript a value of type 'String' with an index of type 'String'" in Xcode
I think there have been no responses, because no-one understands fully.
Is this what you want?
I just set the UISearchBar with a tint colour of deep red - which is the cursor colour
It defaults to a light grey border and black text and a white background.
The light-grey colour can be changed with barTintColor.
By setting barStyle to a UIBarStyle the choices are black, blackOpaque, blackTransparent and default. They can act as a light(default) and dark(black) theme...

Cannot change textcolor for Text in Unity

I need change Text color for UI Text to red, I tried on Indicator and script but the text color still have black color. What is wrong here ?
continueText.color = Red.color;
or
coreText.text = "<color="+textColor+">textContent"</color>";
or
Normally, Font include texture and metarial is packed. Here I make a editable copy of original font so that the metarial is unpacked. We need add metarial to Metarial box under color box choice to change color.
Thanks to #mgear for your help.

Changes Brightness in color replacement

I am working on replacing certain color in image by User's selected color. I am using OpenCV for color replacement.
Here in short I have described from where I took help and what I got.
How to change a particular color in an image?
I have followed the step or taken basic idea from answer of above link. In correct answer of that link that guy told you only need to change hue for colour replacement.
after that I run into the issue similar like
color replacement in image for iphone application (i.e. It's good code for color replacement for those who are completely beginners)
from that issue I got the idea that I also need to change "Saturation" also.
Now I am running into issues like
"When my source image is too light(i.e. with high brightness) and I am replacing colour with some dark colour then colours looks light in replaced image instead of dark due to that it seems like Replaced colour does not match with colour using that we done replacement"
This happens because I am not considering the brightness in replacement. Here I am stuck what is the formula or idea to change brightness?
Suppose I am replacing the brightness of image with brightness of destination colour then It would look like flat replacemnt and image will lose it's actual shadow or edges.
Edit:
When I am considering the brightness of source(i.e. the pixel to be processed) in replacment then I am facing one issue. let me explain as per scenario of my application.
for example I am changing the colour of car(like whiteAngl explain) after that I am erasing few portion of the newly coloured car. Again I am doing recolour on erased portion but now what happended is colour done after erase and colour before erase doesn't match because both time I am getting different lightness because both time my pixel of to be processed is changed and due to that lightness of colour changed in output. How to overcome this issue
Any help will be appreciated
Without seeing the code you have tried, it's not easy to guess what you have done wrong. To show you with a concrete example how this is done let's change the ugly blue color of this car:
This short python script shows how we can change the color using the HSV color space:
import cv2
orig = cv2.imread("original.jpg")
hsv = cv2.cvtColor(orig, cv2.COLOR_BGR2HSV)
hsv[:,:,0] += 100
bgr = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR)
cv2.imwrite('changed.jpg', bgr)
and you get:
On wikipedia you see the hue is between 0 to 360 degrees but for the values in OpenCV see the documentation. You see I added 100 to hue of every pixel in the image. I guess you want to change the color of a portion of your image, but probably you get the idea from the above script.
Here is how to get the requested dark red car. First we get the red one:
The dark red one that I tried to keep the metallic feeling in it:
As I said, the equation you use to shift the light of the color depends on the material you want to have for the object. Here I came up with a quick and dirty equation to keep the metallic material of the car. This script produces the above dark red car image from the first light blue car image:
import cv2
orig = cv2.imread("original.jpg")
hls = cv2.cvtColor(orig, cv2.COLOR_BGR2HLS)
hls[:,:,0] += 80 # change color from blue to red, hue
for i in range(1,50): # 50 times reduce lightness
# select indices where lightness is greater than 0 (black) and less than very bright
# 220-i*2 is there to reduce lightness of bright pixel fewer number of times (than 50 times),
# so in the first iteration we don't reduce lightness of pixels which have lightness >= 200, in the second iteration we don't touch pixels with lightness >= 198 and so on
ind = (hls[:,:,1] > 0) & (hls[:,:,1] < (220-i*2))
# from the lightness of the selected pixels we subtract 1, using trick true=1 false=0
# so the selected pixels get darker
hls[:,:,1] -= ind
bgr = cv2.cvtColor(hls, cv2.COLOR_HLS2BGR)
cv2.imwrite('changed.jpg', bgr)
You are right : changing only the hue will not change the brightness at all (or very weakly due to some perceptual effects), and what you want is to change the brightness as well. And as you mentioned, setting the brightness to the target brightness will loose all pixel values (you will only see changes in saturation). So what's next ?
What you can do is to change the pixel's hue plus try to match the average lightness. To do that, just compute the average brightness B of all your pixels to be processed, and then multiply all your brightness values by Bt/B where Bt is the brightness of your target color.
Doing that will both match the hue (due to the first step) and the brightness due to the second step, while preserving the edges (because you only modified the average brightness).
This is a special case of histogram matching, where here, your target histogram has a single value (the target color) so only the mean can be matched in a reasonable way.
And if you're looking for a "credible source" as stated in your bounty request, I am a postdoc at Harvard and will be presenting a paper on color histogram matching at Siggraph this year ;) .