Comments (5)
If you want to return the exact same color you send, you need to have both SaturationBar
and ValueBar
assigned to ColorPicker
.
colorPicker.addSaturationBar(saturationBar);
colorPicker.addValueBar(valueBar);
This is because HSV colors consist of these three values.
I'm not sure what is SVBar
for here. I initially wanted to use that and had the same issue. It could be replaced with SVTriangle
like on this image: http://pl.wikipedia.org/wiki/Plik:HSV_cone.jpg
@LarsWerkman Very nice design, thank you for putting it on maven central.
from holocolorpicker.
Oh. I translated your colors to hex (#99CC00
and #9ACC00
) and I think the reason here is different. I haven't looked at the code yet, but I guess color is kept inside the library as HSV, when you always set and get it as RGB. Some bits are simply lost in the translation.
from holocolorpicker.
@mg6maciej yes that is exactly what is happening. the reason for this is when setting a color in the color picker you have to translate this to a radial value for the colorpicker and a value for the bars.
and then when you get a value the request the radial value from the colorpicker. thats why you lose some accuracy of the value you put in.
@huteri
from holocolorpicker.
I'm not sure this should be closed without resolving.
When using ColorPicker.setColor
followed by ColorPicker.getColor
, I would expect to get the exact same value at least when all additional View
s (saturation, value) are attached.
It's even more important if you use ColorPicker
together with 3 NumberPicker
s which enable you to set any RGB value. When you change one of the RGB values, it updates ColorPicker
and OnColorChangeListener
is fired to update NumberPicker
s with value often different than original by 1 bit. This blocks user from swiping up/down to change RGB value.
Relevant code:
colorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
@Override
public void onColorChanged(int color) {
redPicker.setValue(Color.red(color));
greenPicker.setValue(Color.green(color));
bluePicker.setValue(Color.blue(color));
}
});
NumberPicker.OnValueChangeListener listener = new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker numberPicker, int oldValue, int newValue) {
int color = Color.rgb(redPicker.getValue(), greenPicker.getValue(), bluePicker.getValue());
colorPicker.setColor(color);
}
};
redPicker.setOnValueChangedListener(listener);
greenPicker.setOnValueChangedListener(listener);
bluePicker.setOnValueChangedListener(listener);
I have made a quick fix for this case: mg6maciej@6f8dd87. It's not a complete solution, but works well with saturation + value bars.
Ideally ColorPicker
should keep the value in RGB and only use HSV for displaying purposes.
from holocolorpicker.
here is my version of the quickfix from mg6maciej https://github.com/mreinerth/HoloColorPicker/compare/hotfix/SetColor_GetColor_consistency. Works perfect for me to fix the problem that u dont get the right color u set before. I use the Colorpicker in a dialog and have additionally a gridview under the picker and bars with predefined colors where a click set the color of the picker and the ok button of the dialog save the color (obtained by getColor) to use as a draw color. When i open the Dialog with the picker i set the oldCentercolor and the color to my saved color value.
from holocolorpicker.
Related Issues (20)
- value = -1? HOT 3
- Taps don't trigger a color change, yet they move the pointer. HOT 1
- Color selection to string HOT 4
- Bar orientation HOT 2
- How can i set the SaturationBar and OpacityBar?
- can not disable the view HOT 1
- About bit HOT 1
- Mirror bars
- Can this libarary add activity call and color result when user select color?
- Can this library pick up color from a circle/ring image HOT 1
- Is it possible to select white as color? HOT 1
- No OnColorSelectedListener-event on SVBar
- Could you please make a release tag?
- How do I use this in my android studio project. I'm new to android studio.
- SaturationBar not properly picking up Value HOT 6
- HoloPicker Size parameters not in documentation
- Will HoloColorPicker design yield less possible color choice than a solid full circle? HOT 2
- This library has a lot of bugs but...
- How to use OnClickListener for Colorpicker HOT 1
- Make focusable as for TV layer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from holocolorpicker.