Results 1 to 4 of 4

Thread: How to properly change the RGB of a button?

  1. #1

    Question How to properly change the RGB of a button?

    This feature was just added in the latest update, but I cannot seem to get my buttons to change color. Since the new parameters are not yet included in the API documentation and the scripting logs have yet to be updated, I was hoping you guys could help me out.

    I've tried using text_color={r,g,b}, but other than the text turning white, it will not change to the RGB color I input (such as 255,51,51 which should be the color red). I've also been unable to figure out the background color parameter; if I could be provided with these, I'd appreciate it very much.

    Thanks for your time guys.

    ~Hiram

  2. #2
    You should probably use color tables with numbers in 0-1 range as that's how every other color in TTS works. So not {255, 51, 51}, but {1, 0.2, 0.2}.

  3. #3
    Join Date
    May 2016
    Posts
    1,022
    Color values are between 0 and 1 instead of 0 and 255.

  4. #4

    Cool

    Thanks a lot guys, I got it workin now; though its pretty simple once you know how to use it, I'll still provide the below information for those who may read this in the future.

    Code:
    function onLoad()
        self.createButton({
            label="Color Change", click_function="changeColor",
            function_owner=self, position={-0.5,0.1,-1.1},
            height=210, width=590, font_size=100, 
            font_color={0.7,1,0.4}, color={0.1,0,0.9},
            })
    end
    And for those who may be unfamiliar with a color chart of 0-1; these extra details I found can be very helpful...


    Question) I'm trying to calculate some RGB colors (0 - 255) for a 0 to 1 scale. Does anyone knows a online converter or it exists a math formula?

    Lets say that I want to convert 125 RGB with (0 to 255 scale) to a 0 to 1 scale.


    Answer) t's simply a case of dividing your RGB value, call it x by 255:

    If x = 95 then your value is 95/255 = 0.37
    The below link is a PDF which details a color palette/chart example with 0-1 color codes; I found it pretty useful for quick reference.

    https://tug.org/pracjourn/2007-4/walden/color.pdf

    Thanks again for your help and replies.

    ~Hiram

Similar Threads

  1. Make button click functions return button parameters and/or index
    By MrStump in forum Scripting Suggestions
    Replies: 0
    Last Post: 05-16-2017, 11:10 PM
  2. [SOLVED] Textures not loading properly on Mac
    By Brewsta in forum Scythe
    Replies: 10
    Last Post: 04-08-2017, 04:26 PM
  3. Replies: 1
    Last Post: 07-10-2016, 06:33 PM
  4. how to properly load 3d model
    By Bartosh in forum General Discussion
    Replies: 3
    Last Post: 02-06-2016, 09:17 PM
  5. [SOLVED] Not Connecting Properly
    By kato42 in forum Technical Support
    Replies: 1
    Last Post: 04-20-2015, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •