I have one rectangle. The width of the rectangle is deciding based on the start time and end time. if startime is 0 and end time 20000 then it will have some 200 width and 100 height. Here hight is constant .
And the colour of the rectangle is calculating based on start colour and end colour. so If I give only start colour,
then the background of the rectangle’s colour is set to that colour. If I give
start colour and end colour then partially it will draw start colour and rest of
the half part of rectangle will be end colour.
For example
start time 0;
end time 20000;
All the time are in milliseconds.
start colour is red
end colour is green.
o-10000 it will be red and 10001 – 20000 green.
Now if I want to get 100th millisecond whats the colour of that rectangle.
What could be the logic I have to use.I dont want to use any HashMap concept.
Is there any colour time interpolation theory? I am very much interested to
calculate all these things. Please help me. I am zero knowledge in this interpolation theory.
What you’re looking for is a gradient. There wouldn’t be any strict rules as to how to display a gradient between red and green. I can imagine you can start from RGB {255, 0, 0} (very red) and then while decreasing the red part, increase the green part {0, 255, 0}. You can now see that there will be 510 (255+255) steps there. 20000 ms / 510 colour values = your step.
Drawing of a similar gradient rectangle is described here:
https://stackoverflow.com/a/4424501/211197
Update it to your needs, add your time step to it, and it should be it, I guess.