Super QUICK Question. How do you store the RGB values in a simple variable?

Order by:
Duplicate Topic
Posts
Views
Last Post
0 favourites
  • 7 posts
From the Asset Store
HSV RGB Color Picker and Converter for Construct 3
  • I just need to store the Red, Green, and Blue values in separate variables so I can manipulate them independently. Can you tell me how to do this really quick please...

    Thanks!

  • I don't know if I understand your question correct, but there is the expression 'rgb'.

    rgb(r, g, b):

    Generate a single number containing a color in RGB format. This is useful for conditions or actions taking a color parameter.

    This number can easily stored in a variable.

  • Thanks for your quick reply.

    Yes, I actually read that from the manual, but I can't actually store the variables.

    Do you have a quick and dirty code sample in written form of how to do this?

    Thanks so much kind sir!!!!!!

  • To make it more clear:

    I want to dynamically change each of the three RGB values seperately.

    I'm just trying to figure out how to store RGB(r, , ) in a variable and the same for the 'g' and 'b'.

  • I want to dynamically change each of the three RGB values seperately.

    Make 3 variables, for example: myR, myG, myB and put they in the rgb expression.

    rgb(myR, myG, myB), now you can put the rgb expression where you want and alter each variable separately

    .

    If this is not what you want, could you provide an example what you want to achieve.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Perfect!

    So how do you put RGB(r, , ) -->> into "myR".

    What's the code to actually store that variable?

  • I don’t recall exactly. You’d have to look at the source or test it. But if you created a color with for example:

    Set color to rgb(12, 33, 177)

    “Color” would be a single number with the three colors packed in.

    Then you could get individual color components from that number with

    Red = color%256

    Green =int( color/256)%256

    Blue = int(color/256/256)%256

    There may also be expressions to help with that but I haven’t checked.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)