How the Hit Point color bar is calculated?
According to Smogon,
The colour of the HP bar is determined as follows: it is green if the pokemon's health is > 50%, yellow if the pokemon's health is <= 50% but > 20%, and red if the pokemon's health is <= 20%.
Green > 50% and yellow > 20%
Therefore, at 50%, the bar is yellow, and at 20%, it is red.
HP is depicted as a long, horizontal bar that changes color according to how much HP the Pokémon has left along with numerical values showing the current and total HP. When a Pokémon's HP is full or above 50%, the bar will appear green. Below 50% but above 20% will cause the bar to appear yellow, while below 20% with the exception of 0% will cause it to appear red.
So
- Green: from full to half (> 50%)
- Yellow: from half (50%) or equals to 20%
- Red: from 20% or equals to 0
source: Pokemon Wikia
From Bulbapedia:
If a Pokémon has more than half of its HP, its HP bar remains green. If the Pokémon has between one-fifth and half of its HP, the bar will turn yellow (in Generation II, a Pokémon revived to exactly half of their HP will have a green HP bar). If a Pokémon has less than one-fifth of its HP remaining, the bar will turn red...
So, if HP > 50%, it will be green; if 50% > HP > 20%, it will be yellow (unless you revive in Gen II); and if HP < 20%, it will be red.
However, in Gen I, it was calculated inaccurately via pixels, causing the bar to turn yellow at about 56% of the max HP:
If the bar's fill was 27 pixels or wider (out of a total end-to-end length of 48 pixels), it would be colored green; if it was between 10 and 26 pixels, it would be colored yellow; and if it was less than 10 pixels wide, it would be colored red. This means the HP bar turns yellow noticeably earlier than in the later games, or at about 56% of the Pokémon's maximum HP.
I hope this answered your question.