Comments (9)
Hi @Horray ,
you forgot to write what to do in line 117:
if (child.id) {
child.children[0].style.width = ((color.RND[type][mode] - ...
So, child.children[0].style.width =
is missing.
Still, Lab is different (negative values and no normalized value range) so it might be more complex to solve that...
BTW: I'm happy to help out if things are not clear with color picker, but I can't spend too much time helping people programming their own things. Please don't put issues on this page that are not really related to clorPicker. Thanks.
from colorpicker.
Oh okay. I understand! But the reason I did ask it here, was because it's related to the documentation page and color.js.
But thanks anyway for your earlier help!
from colorpicker.
Also, the more I look into it, the more I think the problem is with the setColor
function, which ultimately is convertColors
function. So I don't think this is off topic.
from colorpicker.
With setColor you can set a color (or part of a color) and it will then calculate all the other color spaces and return an object including all those:
myColor.setColor({
r: 200,
g: 100
}, 'rgb', 1);
Inspect the returned Object to see what you get
And, if you only want to set alpha:
myColor.setColor({}, 'rgb', 0.5);
...or just set it in myColor.colors.alpha = 0.5
from colorpicker.
With a little outside help, I got the L working correctly but the A and B has weird behavior. I added some code to the slideMove
function:
sliderMove = function (e) {
if (type === 'Lab') {
var currentLab = myColor.colors.Lab;
var factor = (e.clientX - startPoint.left) / currentTargetWidth;
currentLab[mode] = (mode === 'L') ? factor * 100 : (factor * 255) - 128;
var hex = myColor.convertColor(currentLab, 'Lab2HEX');
myColor.setColor(hex, 'hex');
} else {
var newColor = {};
newColor[mode] = (e.clientX - startPoint.left) / currentTargetWidth * max[type][mode][1];
myColor.setColor(newColor, type);
}
}
CodePen
from colorpicker.
That's because you convert to HEX and then set color. The color space of Lab is way bigger then RGB mode...
To set a color, you can just manipulate the color object and then set the color by passing an empty object or even null:
if (type === 'Lab') {
var factor = (e.clientX - startPoint.left) / currentTargetWidth;
factor = factor > 1 ? 1 : factor < 0 ? 0 : factor;
myColor.colors.Lab[mode] = (mode === 'L') ? factor * 100 : (factor * 255) - 128;
myColor.setColor(null, 'Lab');
}
from colorpicker.
Thank you very much! It finally works!!
from colorpicker.
Hi @Horray,
I just updated colorPicker with a demo on how to realize Lab sliders.
Just pull the newest version, remove the comments of the sliders in the index.html and you can use them. Be aware that I changed all the id="rgbr"
like DIVs...
from colorpicker.
Thank you very much! You're a great help!
from colorpicker.
Related Issues (20)
- Unable to add letters to hex code if hex starts with 0
- potential failures with "document"
- WebGL support idea
- Plugin crashes when js files are called from html's head tag instead of body HOT 2
- 8 Digit Hex Code
- Reset all pickers with a single button click [jQuery version]
- Gradients Suggestion HOT 2
- Android web views and Chrome bad rendering HOT 1
- How initialize colorPickers without clicking on element HOT 7
- How to access colorPicker object? HOT 1
- positionCallback
- allMixDetails: false not working
- Picking color from L*a*b parameters HOT 2
- Color is not changing when colorpicker windows is opened and color defined programmatically
- active dev? HOT 1
- CMYK issues HOT 2
- How i can change the color of a div ?
- Integrate with Angular 8 project
- Can't get color-picker to open from input field
- Add to comfyUI manager?
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 colorpicker.