sn0ep
sn0ep

Reputation: 3943

calculation concerning opacity

hi guys i have a kind of math problem

i have the following loop:

for(int i = 10; i < 150; i = i + 5)
{
    imageView.setBounds(
        ini.getMonsterX(monsterName) -i/2,
        ini.getMonsterY(monsterName) -i/2, 
        i, 
        i);
    imageView.repaint();
    imageView.setVisible(true);
    Log.e(TAG, "setSize = "+i );
    r.delay(10);
}

if i = 10 the opacity should be 1.0f and if i = 150 the opacity should be 0.0f

how do i calculate the values in between?

Upvotes: 0

Views: 46

Answers (1)

Eric
Eric

Reputation: 97571

This is basic linear interpolation:

opacity = (150f - i) / (150f - 10f)

Upvotes: 3

Related Questions