[SOLVED] Why the image got dimmer after the animation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

[SOLVED] Why the image got dimmer after the animation?

Hi there! I was working on a code to animate the Indian flag. I tried to draw the image in the form of thin slits displaced along the y-axis by some length (similar to water waves). But, after the animation, the image got dimmer. Why it is so? Thanks in advance! Edit: Added the code https://code.sololearn.com/WmP6CuzCPFta/?ref=app

17th Jul 2018, 6:06 PM
777
777 - avatar
5 Answers
+ 6
Rahul , I don't know if you already solved the problem but I'll answer it anyway. The problem is on line 32, in the drawImage function, you set the dWidth to 0.5 which is only half of the slit width. That draws only half of a slit and leaves a margin between slits. That's why the brightness looks reduced. You should set it to 1. Upon testing, the animation looks pixelated at the top and bottom. Try using 0.9 or anything close to 1 to reduce pixelation.
18th Jul 2018, 1:17 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 3
Please provide the code with you. Otherwise we have no idea what could have made that happen.
17th Jul 2018, 6:07 PM
Andre Daniel
Andre Daniel - avatar
+ 3
Jonathan Pizarra Oh, the 0.5, that's why the brightness seems to be reduced. Thanks a lot!
18th Jul 2018, 2:23 AM
777
777 - avatar
+ 1
Rahul you're welcome. Just a correction on my answer, The 0.5 dWidth doesn't draw only half of a slit. It actually draws the whole slit but compressed by half.👍
18th Jul 2018, 2:30 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
21st Jul 2020, 3:14 AM
shubham kumar
shubham kumar - avatar