Search code examples
rubyfxruby

Making a gradient in FXRuby


Is there a way to create a gradient in FXRuby? If so, how would I implement it?

I have tried looking at https://www.rubydoc.info/gems/fxruby/Fox/FXImage and it didn't make much sense to me, If I could get elaboration on what #gradient means and how to use it, that would be great.


Solution

  • According to the docs here's how you would use the method, but first you'll need to install and require the gem

    gem install fxruby
    

    Then in your code:

    require 'fxruby'
    
    # the arguments represent rgb colors:
    # #gradient(topleft, topright, bottomleft, bottomright)
    

    You'll need to pass the RGB colors you want to use for the actual gradient but here's an example of the syntax

    FXImage.gradient(
      Fox.FXRGB(253, 245, 230), 
      Fox.FXRGB(253, 245, 230), 
      Fox.FXRGB(253, 245, 230), 
      Fox.FXRGB(253, 245, 230)
    )
    

    See here for examples of colors