Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving color picker value as RGB #50

Closed
jasonwebb opened this issue May 25, 2020 · 2 comments
Closed

Retrieving color picker value as RGB #50

jasonwebb opened this issue May 25, 2020 · 2 comments

Comments

@jasonwebb
Copy link

I'm having a little difficulty figuring out how to retrieve the RGB component values of a color picker. When I use the following code, the value of the comps_ array in my value var always seems to be in HSV:

renderingFolder
  .addInput(parameterValues.gradientColors, 'color1RGB', { label: 'Color 1' })
  .on('change', (value) => {
    console.log(value);
});

Where parameterValues.gradientColors.color1RGB = {r:255, g:0, b:0}.

In issue #18 I see that support was added in release 1.2.0 for different output formats based on an input config variable, but for me the mode stays as hsv when I use input: 'color.rgb' (shown below). Is there maybe something small that I'm missing?

[...].addInput(..., 'color1RGB', { label: 'Color 1', input: 'color.rgb' })

Result:

Color: {
  comps_: [array],
  mode: "hsv",
  mode_: "hsv"
}

(btw, loving this library so far! You've done an epic job with the architecture of this thing!)

@cocopon
Copy link
Owner

cocopon commented May 25, 2020

Thank you for using Tweakpane!

Which version of Tweakpane do you use? I released the latest version 1.3.4 yesterday and it fixes a bug about type-mismatching of the first argument of event handlers. Please update the library if you use an old one.

@jasonwebb
Copy link
Author

A-ha! I was using 1.3.3, and I just updated my packages (I'm using npm) and now its working. It even works when I leave out the explicit input config option, so I assume that the initial format of the parameter drives the output format now. Very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants