+ 1
python
You are to read in two pixel values and generate a number of pixels specified between them. Using the 2 pixels specified it will generate 3 new pixels between the first and last pixel. You will need to round the difference of each channel between the larger and smaller pixel. Example ïŒ Enter the first pixel: 0x002222 Enter the second pixel: 0xFFDD33 Enter the number of colours to generate inbetween: 3 Colours: 0x002222 0x405126 0x80802a 0xc0af2e 0xffdd33 How to deal with problem like this ! Thanks in advan
2 Answers
+ 7
In linear interpolation it is really easy. You just have to calculate the RGB differences of the start and end pixels, respectively. For each color its own difference.
Then, assuming that the start pixel is 1, end is 5 and you are looking for color coordinates of 2, 3 and 4, here's what happens:
2 gets the color coords of 1 boosted by 25% of the differences, 3 get 1 + 50% of the diffs and 4 gets 1 + 75% of the diffs.
Of course, that is best done in the hexadecimal mode :)
0
About linear interpolation