# 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
|
|
1 | 1 | r""" |
2 | 2 | Texture Support |
3 | 3 | |
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 |
| 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 |
8 | 8 | :class:`Texture_class <sage.plot.plot3d.texture.Texture_class>` |
9 | 9 | for full details about options and use. |
10 | 10 | |
… |
… |
|
32 | 32 | AUTHOR: |
33 | 33 | |
34 | 34 | - Robert Bradshaw (2007-07-07) Initial version. |
35 | | |
| 35 | |
36 | 36 | """ |
37 | 37 | from sage.structure.sage_object import SageObject |
38 | 38 | |
… |
… |
|
136 | 136 | """ |
137 | 137 | if isinstance(id, Texture_class): |
138 | 138 | return id |
139 | | if kwds.has_key('texture'): |
| 139 | if 'texture' in kwds: |
140 | 140 | t = kwds['texture'] |
141 | 141 | if is_Texture(t): |
142 | 142 | return t |
143 | 143 | else: |
144 | | raise TypeError, "texture keyword must be a texture object" |
| 144 | raise TypeError("texture keyword must be a texture object") |
145 | 145 | if isinstance(id, dict): |
146 | 146 | kwds = id |
147 | | if kwds.has_key('rgbcolor'): |
| 147 | if 'rgbcolor' in kwds: |
148 | 148 | kwds['color'] = kwds['rgbcolor'] |
149 | 149 | id = None |
150 | 150 | elif isinstance(id, Color): |
151 | 151 | kwds['color'] = id.rgb() |
152 | 152 | id = None |
153 | | elif isinstance(id, str) and colors.has_key(id): |
| 153 | elif isinstance(id, str) and id in colors: |
154 | 154 | kwds['color'] = id |
155 | | #kwds = {"color": id} |
156 | 155 | id = None |
157 | 156 | elif isinstance(id, tuple): |
158 | 157 | kwds['color'] = id |
… |
… |
|
193 | 192 | |
194 | 193 | sage: parse_color('red') |
195 | 194 | RGB color (1.0, 0.0, 0.0) |
| 195 | sage: parse_color('#ff0000') |
| 196 | RGB color (1.0, 0.0, 0.0) |
196 | 197 | |
197 | 198 | From a non valid color str:: |
198 | 199 | |
… |
… |
|
211 | 212 | return info.rgb() |
212 | 213 | elif isinstance(info, str): |
213 | 214 | try: |
214 | | return colors[info] |
| 215 | return Color(info) |
215 | 216 | except KeyError: |
216 | | raise ValueError, "unknown color '%s'"%info |
| 217 | raise ValueError("unknown color '%s'"%info) |
217 | 218 | else: |
218 | 219 | r, g, b = base |
219 | 220 | # We don't want to lose the data when we split it into its respective components. |
… |
… |
|
227 | 228 | r""" |
228 | 229 | Construction of a texture. |
229 | 230 | |
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. |
231 | 233 | |
232 | 234 | EXAMPLES: |
233 | 235 | |
… |
… |
|
250 | 252 | r""" |
251 | 253 | Construction of a texture. |
252 | 254 | |
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. |
254 | 257 | |
255 | 258 | EXAMPLES:: |
256 | 259 | |
… |
… |
|
385 | 388 | sage: t = Texture(opacity=0.6) |
386 | 389 | sage: t.jmol_str('obj') |
387 | 390 | 'color obj translucent 0.4 [102,102,255]' |
388 | | |
| 391 | |
389 | 392 | :: |
390 | 393 | |
391 | 394 | 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) |
… |
… |
|
394 | 397 | return "color %s %s [%s,%s,%s]" % (obj, translucent, |
395 | 398 | int(255*self.color[0]), int(255*self.color[1]), int(255*self.color[2])) |
396 | 399 | |
397 | | |
398 | | |