python - Unable to set hsva/hsla attribute of pygame.Color -


as 1 can read in pygame documentation here, pygame.color object has 2 different attributes, namely pygame.color.hsva , pygame.color.hsla can read , assigned to.

however, seem unable this. in fact, running script

import pygame pygame import color c pygame.init()  t = (100, 0, 0, 100)  c = c(0,0,0) print(c.hsva) c.hsva = t print(c.hsva) c = c(100, 45, 10) print(c.hsva) c.hsva = t print(c.hsva) 

prints unexpected results, namely

(0.0, 0.0, 0.0, 100.0) (0.0, 0.0, 0.0, 100.0) (23.333333333333336, 89.99999999999999, 39.21568627450981, 100.0) (0.0, 0.0, 0.0, 100.0) 

which shows not being able assign .hsva attribute (changing "hsva" "hsla" shows same erratic behaviour). furthermore, after defining new color , trying change .hsva color changes completely.

am missing or bug?

to make easier others take useful visiting question in future let me summarize in answer outcome of discussion:

the in question provided code not show bug in pygame nor show unexpected behavior.

to understand .hsva get/set worked expected necessary aware of how colour schemes work in pygame, not making error of thinking changing hue change colour itself, regardless of saturation , value.

the pygame.color object stores color value internally rgb.

so if saturation , value both 0, hue won't affect rgb values @ - zeros. so, when ask hsva representation of rgb values, hue anything, , seems default zero.

a hue of anything, saturation , value of zero, represented in rgb (0, 0, 0). changing hue, thus, not affect rgb whatsoever.


Comments

Popular posts from this blog

php - Displaying JSON data posts for blog using just the post id -

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

javascript - Angular2 intelliJ config error.. Cannot find module '@angular/core' -