Getting and changing JUST the transparency of a pre-defined color variable.

This is probably simple, but how can I get and change the alpha of a pre-existing color set to a variable?

So I can have a variable like this


myColor = Color(150,150,150,255)

and with a function like


newColor = ChangeAlpha(myColor, 150)

I would get a new variable to use
So I would have 2 variables with the same RGB but different alpha’s (allowing for “parent” colors that have RGB values passed onto other colors but with different alpha’s)

Mycolor.a = newAlpha

If I remember correctly, the Color object saves its arguments in fields such as

color.r color.b color.g color.a

so you could do:


newColor = Color(myColor.r, myColor.b, myColor.g, 150)

or


newColor = myColor
newColor.a = 150

EDIT:
that is if u wanted to duplicate it, if not then use the comment above.