Ticket #12904: trac_12904.patch

File trac_12904.patch, 3.7 KB (added by aapitzsch, 9 years ago)
  • sage/plot/plot3d/texture.py

    # HG changeset patch
    # User André Apitzsch <andre.apitzsch@st.ovgu.de>
    # Date 1336154145 -7200
    # Node ID 868ca9b5ed62623a4b68986849a236b3e7168c7e
    # Parent  797ee7641e99db00561f25d6b36b35c3dcb91bc7
    trac 12904: HTML hex color is a valid color string
    
    diff --git a/sage/plot/plot3d/texture.py b/sage/plot/plot3d/texture.py
    a b  
    11r"""
    22Texture Support
    33
    4 This module provides texture/material support for 3D Graphics 
    5 objects and plotting.  This is a very rough common interface for 
    6 Tachyon, x3d, and obj (mtl).   See 
    7 :meth:`Texture <sage.plot.plot3d.texture.Texture>` and 
     4This module provides texture/material support for 3D Graphics
     5objects and plotting.  This is a very rough common interface for
     6Tachyon, x3d, and obj (mtl).   See
     7:meth:`Texture <sage.plot.plot3d.texture.Texture>` and
    88:class:`Texture_class <sage.plot.plot3d.texture.Texture_class>`
    99for full details about options and use.
    1010
     
    3232AUTHOR:
    3333
    3434- Robert Bradshaw (2007-07-07) Initial version.
    35    
     35
    3636"""
    3737from sage.structure.sage_object import SageObject
    3838
     
    136136    """
    137137    if isinstance(id, Texture_class):
    138138        return id
    139     if kwds.has_key('texture'):
     139    if 'texture' in kwds:
    140140        t = kwds['texture']
    141141        if is_Texture(t):
    142142            return t
    143143        else:
    144             raise TypeError, "texture keyword must be a texture object"
     144            raise TypeError("texture keyword must be a texture object")
    145145    if isinstance(id, dict):
    146146        kwds = id
    147         if kwds.has_key('rgbcolor'):
     147        if 'rgbcolor' in kwds:
    148148            kwds['color'] = kwds['rgbcolor']
    149149        id = None
    150150    elif isinstance(id, Color):
    151151        kwds['color'] = id.rgb()
    152152        id = None
    153     elif isinstance(id, str) and colors.has_key(id):
     153    elif isinstance(id, str) and id in colors:
    154154        kwds['color'] = id
    155         #kwds = {"color": id}
    156155        id = None
    157156    elif isinstance(id, tuple):
    158157        kwds['color'] = id
     
    193192
    194193        sage: parse_color('red')
    195194        RGB color (1.0, 0.0, 0.0)
     195        sage: parse_color('#ff0000')
     196        RGB color (1.0, 0.0, 0.0)
    196197
    197198    From a non valid color str::
    198199
     
    211212        return info.rgb()
    212213    elif isinstance(info, str):
    213214        try:
    214             return colors[info]
     215            return Color(info)
    215216        except KeyError:
    216             raise ValueError, "unknown color '%s'"%info
     217            raise ValueError("unknown color '%s'"%info)
    217218    else:
    218219        r, g, b = base
    219220        # We don't want to lose the data when we split it into its respective components.
     
    227228    r"""
    228229    Construction of a texture.
    229230   
    230     See documentation of :meth:`Texture <sage.plot.plot3d.texture.Texture>` for more details and examples.
     231    See documentation of :meth:`Texture <sage.plot.plot3d.texture.Texture>`
     232    for more details and examples.
    231233
    232234    EXAMPLES:
    233235
     
    250252        r"""
    251253        Construction of a texture.
    252254       
    253         See documentation of :meth:`Texture <sage.plot.plot3d.texture.Texture>` for more details and examples.
     255        See documentation of :meth:`Texture <sage.plot.plot3d.texture.Texture>`
     256        for more details and examples.
    254257
    255258        EXAMPLES::
    256259
     
    385388            sage: t = Texture(opacity=0.6)
    386389            sage: t.jmol_str('obj')
    387390            'color obj translucent 0.4 [102,102,255]'
    388            
     391
    389392        ::
    390393
    391394            sage: sum([dodecahedron(center=[2.5*x, 0, 0], color=(1, 0, 0, x/10)) for x in range(11)]).show(aspect_ratio=[1,1,1], frame=False, zoom=2)
     
    394397        return "color %s %s [%s,%s,%s]" % (obj, translucent,
    395398                int(255*self.color[0]), int(255*self.color[1]), int(255*self.color[2]))
    396399
    397 
    398