ThomasNL
ThomasNL

Reputation: 359

Color Variables but Alpha Separate

I stored all basic colors in variables for example:

WHITE = (255, 255, 255)

I then use those variables to draw ellipes, but i want different alpha values for those ellipses. I dont want to create variables for all the different alpha values. I tried doing

pygame.draw.ellipse(self.image, (WHITE, 50), self.rect) 

But that does not work sadly. Any Solution?

Upvotes: 1

Views: 31

Answers (1)

unutbu
unutbu

Reputation: 879591

Tuples can be concatenated by addition:

pygame.draw.ellipse(self.image, WHITE + (50,), self.rect) 

For example,

>>> (255, 255, 255) + (50,)
(255, 255, 255, 50)

Lists, by the way, behave analogously:

>>> [255, 255, 255] + [50]
[255, 255, 255, 50]

Upvotes: 1

Related Questions