• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Color software

Gatefiz

Member
Hi,
I'm trying to make a software where I can put hexa color, and it draw rectangle with this color.
I can easily do it with rgb, but I need to put hexa code.
I tried to:
text = keyboard_string
color = string_lettersdigits(text)

But, it's always a string, and it needs a number.

Can someone help me ?
 

Binsk

Member
There isn't a built in way but the conversion isn't hard.

You can make a color via make_color_* functions. You can get the hex as a string. You need to manually parse the string into values you can pass into make_color_*
 

Gatefiz

Member
Then, I have to take my string, and transform values as numbers ?
Like "e000d8" = 14680280 ?
I'm not sure to understand =(
 

TailBit

Member
I missread the question .. nwm
From the gamemaker help file:
scripting > gml_reference > drawing > colour
Note that you can also create colours from their hexadecimal value using the "$" symbol beforehand, and these values can also be used in the colour functions to get component hues or for mixing, etc... The hexadecimal value for these colours is split into three parts with the format Blue / Green / Red so, for example, to define a purple colour you could use:

Code:
col = $983c95

This page always got some good scripts for things like this:
https://www.gmlscripts.com/script/hex_to_color

It seems that scripts needs this one:
https://gmlscripts.github.io/script/hex_to_dec
 
Last edited:

Gatefiz

Member
Yeah I seen that I can create color.
I can do it at create event, and it works perfectly.
But I need to write color in a box, and this box need to change color by what I wrote.
And my problem is, when I do "text = keyboard_string", it's a string, then I can't say color = text
Or maybe I didn't understood what you said ^^.

Edit--> I'll watch your link, maybe I'll find what I need =)
 
Top