User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: How to change RGB Coefficient at runtime?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,202
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Question How to change RGB Coefficient at runtime?

    I am trying to change the colour of a white box so it blends into different colours, it might go from red to gren and then to yellow and blend back to another colour etc etc etc. But I have not found a way to easely do it. Do anyone know how to do this? If I just try to use the action set RGB coefficient I don't get the intended result so I must be missing something.

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleXNA Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    piscesdreams's Avatar
    Join Date
    Dec 2007
    Location
    United States
    Posts
    1,010
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You can set the RGB coefficient under the active object, then get the RGB values using the Special "GetRGB" action. It allows you to isolate the R,G and B values separately. I find it's best to use dedicated alterable values for each of the RGB values.

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,501
    Mentioned
    131 Post(s)
    Tagged
    0 Thread(s)
    It can take a bit of trial and error to get the color you want, as the RGB tends to work differently to how you're probably used to it. It tends to be a 'subtractive' process. All graphics have a RGB of 255,255,255 by default, even when they're not all white (as most graphics aren't, of course). To get them to tint a color that you want, you then need to subtract from 255. So if you want something to go red, you can't just add red, since red is already at 255 (the max). So you instead have to subtract green and blue. How much you need to subtract them will depend on how much green and blue there is in the source active: eg. if your active has lots of purple in it, then you might need to subtract lots of blue but only a little green.

    Though in your current case you just have a white box, so that should make it easier. Just remember that you'll often be subracting, not adding. Don't make the mistake of thinking 'oh, I'll just add a bit of red, so I'll try SetRGB to GetRGB(100,0,0), as that will probably make your result too dark, since you've not only stripped all blue and green, but also stripped most of the red (from 255 down to 100). So instead try something like SetRGB to GetRGB(255,50,50)

  4. #4
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    655
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Like Volnaiskra said, but personally I like to think of the RGB coefficient as a multiply layer filled with a solid colour (that you pass in) above the sprite, like you could do in Photoshop.
    To cycle through colours/hue, it'd be best to do this in HSV (Hue, Saturation, Value) rather than RGB (Red, Green, Blue) as it is more intuitive for humans as well as makes hue cycling as trivial as always adding 1 to a variable.

    The attached example does just that, and includes a HSV -> RGB converter: HueShift_HSV_RGB.mfa
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/7RNXFrC
    Dungeon Raiders! - Link soon™

  5. #5
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,501
    Mentioned
    131 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BartekB View Post
    .........includes a HSV -> RGB converter...
    Woohoo! Thanks for sharing this. It'll come in useful for me for sure!

    There's no possible way to make a pixel brighter than its original using the SetRGB method, is there? Like you say, it seems like using Multiply in Photoshop, where you can make various pixels a bit darker, a lot darker, or unchanged, but never brighter.

    Or, to put it a different way, there's no limit to how much SetRGB can change a pure white pixel, whereas SetRGB can't make any change at all to an already black pixel. Is that correct?

  6. #6
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    655
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    That's correct, with the RGB coefficient it is not possible to get a brighter result because colour works in a 0.0 to 1.0 range.
    and when you multiply something with 1.0 (white coefficient), you get the same original thing back, but multiply something with 0.0 (black coefficient) and you get 0.0 (black).
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/7RNXFrC
    Dungeon Raiders! - Link soon™

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleXNA Export Module
    Dobermann's Avatar
    Join Date
    Feb 2009
    Location
    France
    Posts
    820
    Mentioned
    37 Post(s)
    Tagged
    0 Thread(s)
    Didn't knew that GetRGB function exists... There so much things that are hard to find in Fusion...

    I'd created a simple formula to use it:

    Set RGB coefficient to Red Value + ( Green Value * 256 ) + ( Blue Value * 65536 )

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,202
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Hmm I am stuck at the GetRGB action. I just grab it from my active (at pixel 30,30 though I dont think that matters), but I always get the same number 15793151 no matter what RGB coefficient I have set it to in the frame?

    I did manage to change the hue though by just increasing the rgb value at runtime, but only in bluish color and it "snaps" at a point and resets. I want to have the white box go from blue, to green to red etc etc (not in that particular order) and always changing. No idea how the logic behind all this works now though

    Any ideas?

    HugeChange.mfa

  9. #9
    Clickteam Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    BartekB's Avatar
    Join Date
    Aug 2013
    Posts
    655
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Outcast View Post
    Hmm I am stuck at the GetRGB action. I just grab it from my active (at pixel 30,30 though I dont think that matters), but I always get the same number 15793151 no matter what RGB coefficient I have set it to in the frame?

    I did manage to change the hue though by just increasing the rgb value at runtime, but only in bluish color and it "snaps" at a point and resets. I want to have the white box go from blue, to green to red etc etc (not in that particular order) and always changing. No idea how the logic behind all this works now though

    Any ideas?

    HugeChange.mfa
    You shouldn't ever add/subtract to the RGB coefficient directly. Because RGB coefficient is an integer holding 3 values.

    See Dobermann's expression:

    Quote Originally Posted by Dobermann View Post
    I'd created a simple formula to use it:
    Set RGB coefficient to Red Value + ( Green Value * 256 ) + ( Blue Value * 65536 )
    This is what "RGB coefficient" is equal to. For reverse, the expression would be:
    Red = RGB mod 256
    Green = (RGB / 256) mod 256
    Blue = (RGB / 65536) mod 256

    By adding 1 to RGB coefficient, you're adding 1 to Red. If Red exceeds 255, Red is reset back to 0 and 1 is added to Green. This is what causes that "snap"

    You always get 15793151 because RGBAt retrieves original colour from the sprite, not colour that was applied with RGB coefficient.

    Look at my previous example that I have posted here with the hue change, it's not as simple as adding 1: HueShift_HSV_RGB.mfa
    Edit: You're also using RGBAt, nowhere in the file was GetRGB used, they're two different expressions. The latter "makes" the integer value RGB coefficient uses (easy solution to not deal with writing the expression Dobermann wrote above)
    - BartekB, a.k.a Uppernate
    Join the Click Converse Discord! - https://discord.gg/7RNXFrC
    Dungeon Raiders! - Link soon™

  10. #10
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,501
    Mentioned
    131 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dobermann View Post
    Didn't knew that GetRGB function exists... There so much things that are hard to find in Fusion...
    True. It feels almost like a puzzle mini-game to figure out how to change a hotkey, for example

    But to be fair, when it comes to actions/conditions/expressions, most of the hard-to-find things are actually all in one spot - the Special Object (well, 3 spots I guess, since it exists in action, condition, and expression forms). Here's GetRGB:



    I've learnt to peruse the Special Object from time to time, to be reminded of what things are available. There are a lot of functions crammed into that one object, but they're all there categorised in the drop menus.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Dinamically change RGB coefficient
    By nyme in forum Fusion 2.5
    Replies: 2
    Last Post: 15th October 2016, 09:25 PM
  2. changing RGB coefficient for individual layers at runtime
    By willy in forum iOS Export Module 2.5
    Replies: 0
    Last Post: 19th July 2016, 12:35 PM
  3. How do I change RGB Coefficient
    By ionside in forum Hardware Accelerated Runtime
    Replies: 3
    Last Post: 29th June 2010, 11:47 PM
  4. Anyone know how to change the RGB Coefficient...
    By Krim in forum Hardware Accelerated Runtime
    Replies: 1
    Last Post: 3rd October 2008, 12:07 AM
  5. control of RGB and blend coefficient at runtime?
    By BrashMonkey in forum Hardware Accelerated Runtime
    Replies: 2
    Last Post: 11th January 2008, 12:24 AM

Posting Permissions

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