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

getHex/setHex are broken for ofFloatColor/ofShortColor #1487

Closed
kylemcdonald opened this issue Aug 13, 2012 · 5 comments
Closed

getHex/setHex are broken for ofFloatColor/ofShortColor #1487

kylemcdonald opened this issue Aug 13, 2012 · 5 comments

Comments

@kylemcdonald
Copy link
Contributor

one solution is to pre-scale or post-scale the inputs/outputs using the limit() method for division/multiplication.

the best solution would also maintain the speed of the current implementation for ofColor, and not do any unnecessary scaling in that case.

@arturoc
Copy link
Member

arturoc commented Aug 13, 2012

what about making a specialization for ofColor?

template<>
float ofColor_<unsigned char> getHsb(){
   //non-scaled version
}

@kylemcdonald
Copy link
Contributor Author

that's really smart. then you could wrap it by casting to ofColor for the other cases, right?

template<class PixelType>
int ofColor_<PixelType>::getHex(){
    return ((ofColor) *this)::getHex();
}
template<>
int ofColor_<unsigned char>::getHex(){
    //non-scaled version
}

@arturoc
Copy link
Member

arturoc commented Aug 13, 2012

yeah i was actually thinking on doing 2 versions but that is even better

@arturoc
Copy link
Member

arturoc commented Aug 13, 2012

mmh, actually you'll need to do some post scaling, if you'll be returning an ofColor_ it will work automatically but since it's a number you'll need to scale it before returning but the rest should work

@thiagohersan
Copy link
Contributor

closed by #1814

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

4 participants