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

Color.from_hsv() is no longer available in master due to core binding changes #45450

Closed
Calinou opened this issue Jan 25, 2021 · 7 comments
Closed

Comments

@Calinou
Copy link
Member

Calinou commented Jan 25, 2021

Godot version: Git 161c4be

OS/device including version: Fedora 33, GeForce GTX 1080 (NVIDIA 460.32.03)

Issue description:

SCRIPT ERROR: Parse Error: Cannot find property "from_hsv" on base "Color".
          at: GDScript::reload (res://Node2D.gd:6)
SCRIPT ERROR: Parse Error: Function "from_hsv()" not found in base Color.
          at: GDScript::reload (res://Node2D.gd:6)
ERROR: Method/function failed. Returning: ERR_PARSE_ERROR
   at: reload (modules/gdscript/gdscript.cpp:832)

In 3.2, running the code results in:

1,0,0,1
0.45,0.5,0.25,1

The Color.from_hsv() method isn't exposed anymore in master:

// FIXME: Color is immutable, need to probably find a way to do this via constructor
//ADDFUNC4R(COLOR, COLOR, Color, from_hsv, FLOAT, "h", FLOAT, "s", FLOAT, "v", FLOAT, "a", varray(1.0));

Steps to reproduce:

extends Node2D

func _ready():
	print(Color(1, 0, 0))
	var color := Color()
	print(color.from_hsv(0.2, 0.5, 0.5))  # Error.

Minimal reproduction project: test_color_from_hsv.zip

@Bhu1-V
Copy link
Contributor

Bhu1-V commented Jan 27, 2021

hello @Calinou Can u please explain me what bind_method() does In
godot/core/variant/variant_call.cpp
and also I can't Understand why Color is Immutable.

if we can't do anything about the immutability of Color isn't it good to make color properties (like : r,g,b) private and make some getter_functions for retrieving values of those properties.
because I tried changingcolor.r = 5 which resulted in making color.r value to 0. and also update the doc specifying that color is immutable.

if these ideas are good i'm happy to work on it.

@Calinou
Copy link
Member Author

Calinou commented Jan 27, 2021

@Bhu1-V Sorry, I don't understand the cause of the regression either.

@Bhu1-V
Copy link
Contributor

Bhu1-V commented Jan 27, 2021

I'm trying to make a constructor of type Color(r,g,b,a, bool is_hsv
[anything other than zero takes hsv value. but this value defaults to zero so always takes as rgb values but when the last argument is true acts as hsv values]
). is this useful 🤔

@Bhu1-V
Copy link
Contributor

Bhu1-V commented Jan 28, 2021

@Calinou Is it a good idea to make a temporary fix or find what caused this regression in the first place and fix it..??🤔

@Calinou
Copy link
Member Author

Calinou commented Jan 28, 2021

Is it a good idea to make a temporary fix or find what caused this regression in the first place and fix it..??:thinking:

This regression is caused by a Variant core refactoring that was done in the master branch by reduz a few months ago. Since he's working on the renderer right now, I'd prefer if we didn't bother him about this just yet 🙂

@akien-mga
Copy link
Member

Note that's not a very easy issue to solve for a new contributor as it requires some design decision on how we want to expose such functionality going further. We can't have static methods yet, so this one is a bit tricky and probably requires a good amount of experience to find a good solution.

I don't want to discourage you from working on this but it's worth noting :)
There are simpler issues with the junior job label which you can maybe work on: https://github.com/godotengine/godot/labels/junior%20job

@Calinou
Copy link
Member Author

Calinou commented Feb 8, 2021

Duplicate of #43311.

@Calinou Calinou closed this as completed Feb 8, 2021
@Calinou Calinou removed this from the 4.0 milestone Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants