We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Newbie here... I have hex color information in an XML file and want to fill my rectangles with the colors from the XML file. Can someone explain to me how I can accomplish this?
Answers
what xml file?
what rectangles?
you're asking us to guess a lot of information before we can help.
https://processing.org/reference/XML.html
https://processing.org/reference/fill_.html
https://processing.org/reference/rect_.html
In my XML file the setup is like..
and in the processing the rectangles i want to fill are from this code. i cant figure out how to take the hex color information from the XML file and use it to fill those rectangles
You may need to play with this further to get the exact effect you are looking for, but it will read out hex colours from XML and fill rectangles accordingly
line 17 is taking the #123456, removing the initial # and prepending FF to give "FF123456"
line 18 is converting this from hex into a value the fill command understands.
the initial FF is there to set the alpha to fully on, otherwise you'll get a transparent colour.
it's a nice, short solution. it looks a bit odd but that's mostly getting the data from a string to something processing can use.
Dunno whether it's any faster or slower, but here's an alternative version w/
replace("#", "FF")
in place of"FF" + substring(1)
: :ar!