I can defenitly see how imagining a buddha when angry can temporarily distract one from impure thoughts but how does this prevent the thoughts from arising in the future.
I hope I am not butting in here. I gather the discussion is about dealing with unwholesome mental states, such as resentment, that arise during daily interactions?
This goes to #6 in the 8-fold path, usually referred to as Right Effort. A more detailed explanation is the fourfold right struggle. The struggle involves:
1. Blocking the unwholesome mental states before they arise.
2. Letting go of or abandoning unwholesome mental states that have arisen.
3. Cultivating wholesome mental states that have yet to arise.
4. Maintaining wholesome mental states that have arisen
Dosa or dvesha; hostility or hatred is one category of afflictions (klesha) or unwholesome (akushala) mental states. Resentment (upanaha) or anger (pratigjha) can arise in response to annoying actions of others, or even inanimate things, like bad weather, that interfere with our plans. Nursing a grudge can make us spiteful (pradasha). Envy (issa, irsya), a resentment toward the successes or well being of others, is another common form of hostility. Sometimes, people can become dominated by feelings of enmity (vyapada) and develop 'a chip on the shoulder' that tends to provoke uneasiness in others. They might also fly into rage (krodha) at the slightest offense. In extreme cases, people can become dominated by malevolence (vihimsa) toward specific groups or others in general
iirc, in the Path of Purification, Budagosa recommended cultivating tolerance (khanti / kshanti) as means of dealing with felling of resentment or hostility. Khanti or Buddhist tolerance is patience with things that do not necessarily deserve patience. It is synonymous with forbearance and similar to forgiveness, The Chinese for tolerance is 忍辱; which means to endure offenses, insults, or abuse. People generally do what they do because of their own karma, We get annoyed because we see our self as the target of rudeness or inconsiderate deeds committed by others, We think ii is happening to us. In reality, we are usually no more their target than we are the target of bad weather. Budagosa compared harboring resentment to seizing a hot ember with the intent of throwing it at the offender. We get burnt.
Another way of countering anger is to cultivate the mental states known as the 4 palaces of Brahma; loving kindness, compassion, appreciative joy, and equanimity. There are fairly easy and powerful meditations and chants to arouse loving kindness (metta, maitri) and compassion (karuna) within ourselves. There are also practices to radiate or suffuse kindness and compassion outwardly. The effect of the latter on others can be quite remarkable.
There are downsides. Loving kindness can be mistaken for or mixed up with sexual attraction. Lust (kama) is a 'hot' desire, and a near enemy of the warm affection of loving kindness. Metta / maitri is like parental or fraternal love. Also, compassion can make one too emotional. Emotional attachment (raga) can be a near enemy of both compassion (karuna -- empathy with and sadness for the suffering of others) and appreciative joy (mudita -- joy in the well being of others). Cultivating 'cool' and mildly aloof detachment (viraga) and equanimity (upekkha / upeksha) serve as balances for emotionalism. They also strengthen our tolerance level, and counteract the complications or temptations of inappropriate sexual lust.
One other thing on tolerance, We can also get angry at our own mistakes, or even feel anxiety and depression (kukkucca, kaukritya). It is healthy to be patiently forbearing with oneself too.