Hi,
one more issue for today. :-)

If you call the method hsb() of an pyx.color.hsb instance, you get
a reference to the instance itself.

If you call the method rgb() of an pyx.color.hsb instance, you get
a new instance of pyx.color.rgb.

For an instance of pyx.color.rgb you have the same behavior, just
vice versa. This causes some problems as you can see in the example
below.

################################################################

#!/usr/bin/env python

import pyx

def alteredColor(oldColor):
        newColor = oldColor.hsb()

        ### workaround ###
        #newColor = pyx.color.hsb()
        #newColor.color = dict(oldColor.hsb().color.items())
        ###

        newColor.color['s'] = 0.5
        return newColor


rgbCol = pyx.color.rgb(0.1, 0.1, 0.1)
hsbCol = pyx.color.hsb(0.2, 0.2, 0.2)

newRgbCol = alteredColor(rgbCol)
newHsbCol = alteredColor(hsbCol)

print rgbCol.color # should be (0.1, 0.1, 0.1): ok
print hsbCol.color # should be (0.2, 0.2, 0.2): not ok

################################################################

The hsbCol instance was unintentionally altered. What's The Right
Thing to do? Maybe PyX should return a new instance in any case.

Thanks in advance,
Tom

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to