6 Replies Latest reply: May 31, 2011 5:04 AM by 859820 RSS

    Bind RGB color to timeline

    859820
      Hi everybody,

      I am playing around with Javafx and I have run into a problem that prevents me from doing what I wish. I basically want to create an object that changes color according to value from 3 different timelines. I am trying to use a radialGradient Color with RGB like so:

      Circle {
      centerX: 300, centerY:250
      radius:60
      opacity:0.6
      fill: RadialGradient {
      proportional:true
      centerX: 0.5
      centerY: 0.5
      focusX: 1.0
      focusY: 1.0
      radius: 1.0
      stops: [
      Stop {
      color : bind Color.rgb(t1, t2,t3) // <------Stuck here
      offset: 0.2
      }
      Stop {
      color : Color.rgb(155,84,12)
      offset: 1.0
      }
      ]
      }

      onMouseMoved: function(e: MouseEvent):Void{
      t.play();
      t2.play();
      t3.play();
      }

      }

      t1,t2 and t3 are the different timelines..

      Help would be appreciated.. Thanks
        • 1. Re: Bind RGB color to timeline
          Narayan
          Hello I couldn't understand what you are willing to tell.
          856817 wrote:
          color : bind Color.rgb(t1, t2,t3) // <------Stuck here
          I don't think Color.rgb() takes paramater of Timelines.

          Thanks.
          narayan
          • 2. Re: Bind RGB color to timeline
            859820
            I want to create an object(Like a circle) that changes color according to a variable and I am trying to bind the variable to a timeline. Can you please help or give a helpful suggestion?
            • 3. Re: Bind RGB color to timeline
              Narayan
              For your Information: Use the powerful bind features of Javafx . See this demo application which might be helpful for you:

              var red:Integer;
              var green:Integer;
              var blue:Integer;
              
              
              var circle:Circle = Circle{
                  centerX:50
                  centerY:50
                  radius:50
                  fill:bind Color.rgb(red, green, blue);
              }
              
              
              
              var timeline:Timeline = Timeline {     
                   keyFrames: [
                        at (10s) { red => 255 }
                              at (10s) { blue => 200}
                              at (10s) { green => 150 }
                   ];
              }
              timeline.play();
              In above code the Circle's fill color is changed on changes of keyframes from timeline


              Thanks.
              Narayan
              • 4. Re: Bind RGB color to timeline
                859820
                Thank you for your response but I would like to know if I can use a radial gradiant color instead of a solid fill?
                • 5. Re: Bind RGB color to timeline
                  DarrylBurke
                  You've been given a good example. Now try applying that to your need, and post the code you tried.

                  Before you do that, please go through the announcement(s) at the top of the forum topic listing and the FAQ linked from every page. They are there for a purpose.

                  db
                  • 6. Re: Bind RGB color to timeline
                    859820
                    I have tried that before.. That is pretty much the only way I have gotten it to work.. Can't make it use radial gradient instead of solid fill.. The code I tried is in my first post btw

                    Thank you kindly