How do you convert a color slot to a hex value?

I am currently working on a Snap 10.0 project, and I need a mandatory color block.
How do you convert rgba([r],[g],[b],1) to #[r hex][g hex][b hex]?
[scratchblocks](# [​] :: operators)[/scratchblocks] should return #ffffff and not rgba(255,255,255,1)

If you want a color block, you may want to look into the colors and crayons library. It has the ability to convert colors to many different formats.

But of course to answer your question, you just have to split the color into a list of 4 values (if you want to add alpha). Here's the script used in the colors and crayons library.

(you can ignore the costume creating part)

Once you have a list of the values, it's just a matter of converting each value to hex, which isn't too difficult to search up.

ok

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.