i try to get the hsb values from ofColor.
it works fine for single values like "print(color:getHue());"
but if i have more than 2 arguments like "print(color:getHsb(2.0, 4, 5.0));" I get the error message: "expected 'float &' got 'number'."
perhaps it is because the floats that are not the first and the last argument and end with .0 become integers? just a guess.
I think because of that it is not possible to use :getHsb at the moment?
ofeliagethsb.pd
-
ofelia: expected 'float &' got 'number'
-
@Jona Hi,
ofColor::getHsb()
function takesfloat &hue, float &saturation, float &brightness
arguments.In C++, a function can expect arguments to be passed by reference which means the reference to the variable will be passed to the function instead of copied alias. It is used when you need to reuse the passed variables after calling the function. Sometimes, it is also used to create a getter function that returns multiple variables just like
ofColor::getHsb()
.You will understand what I mean if you see the example code: https://openframeworks.cc/documentation/types/ofColor/#show_getHsb
Unfortunately, Lua doesn't have such
pass by reference
feature, so currently you can't expectofColor::getHsb()
function to work like it works in C++. Instead, you would need to useofColor::getHue()
,ofColor::getSaturation()
andofColor::getBrightness()
.There are a few getter functions that work like
ofColor::getHsb()
in openFrameworks and I can make them work in Lua with some modification in SWIG interface. (e.g. make the function return a table instead)Please feel free to report if you find such unsupported functions. I will try to support them as soon as possible.
-
@Cuinjune thanks for the clarification. Sometimes I am not sure if I find an unsupported function or if I just use a supported function the wrong way. But I will report when I get stuck and do not find a solution by myself (or with the help from a search engine).