+2 votes

image

Godot version 3.3.2
in Engine by (179 points)

1 Answer

+2 votes
Best answer

I'm not realy sure what you are asking?
Could you give an example of your hsv and equivalent rgb values.

Basically the Color.from_hsv expects the values to be in the range of 0 - 1.
The saturation and the value are already in the 0 to 1 range.
This leaves the hue which is between 0 and 360.
To have it in the range of 0 - 1 you need to divide it by 360.

In the sample you put up there

var c = Color.from_hsv(210/360.0, 0.5, 0.79, 0.8)

Is this what you are looking for?

by (244 points)
edited by

Well I tried dividing the hue but it just doesn't work:
I have this color:

HSV: 175°, 43%, 72% - #a shade of cyan

And in Godot it becomes:

175/360, 0.43, 0.72 - #an ugly red

Which are seen as two completely different color.

I have not tested it yet, but it could be of integer division instead of float division.

Can you try with "175.0/360"

I tried doing this before with the "float" function and it didn't work. Somehow putting a ".0" did. Thanks a bunch!

I tried doing this before with the "float" function and it didn't work. Somehow putting a ".0" did.

I assume that's because you tried something like:

float(175/360)

That won't work, as it still does integer division, and then coverts the result to a float value. So, you still only have the precision of the original integer result.

Instead, you need to ensure that at least one value in the equation is a float. That can be done line this:

float(175) / 360

... or ...

175.0 / 360

Wouldn't have though ab that tbh

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.