36
36
37
37
from sage .misc .classcall_metaclass import ClasscallMetaclass , typecall
38
38
from sage .misc .fast_methods import WithEqualityById
39
- from sage .structure .sage_object import SageObject
40
-
41
39
from sage .plot .colors import colors , Color
40
+ from sage .structure .sage_object import SageObject
42
41
43
42
44
43
uniq_c = 0
@@ -57,25 +56,7 @@ def _new_global_texture_id():
57
56
"""
58
57
global uniq_c
59
58
uniq_c += 1
60
- return "texture%s" % uniq_c
61
-
62
-
63
- def is_Texture (x ):
64
- r"""
65
- Deprecated. Use ``isinstance(x, Texture)`` instead.
66
-
67
- EXAMPLES::
68
-
69
- sage: from sage.plot.plot3d.texture import is_Texture, Texture
70
- sage: t = Texture(0.5)
71
- sage: is_Texture(t)
72
- doctest:...: DeprecationWarning: Please use isinstance(x, Texture)
73
- See https://github.com/sagemath/sage/issues/27593 for details.
74
- True
75
- """
76
- from sage .misc .superseded import deprecation
77
- deprecation (27593 , "Please use isinstance(x, Texture)" )
78
- return isinstance (x , Texture )
59
+ return f"texture{ uniq_c } "
79
60
80
61
81
62
def parse_color (info , base = None ):
@@ -124,21 +105,22 @@ def parse_color(info, base=None):
124
105
"""
125
106
if isinstance (info , Color ):
126
107
return info .rgb ()
127
- elif isinstance (info , str ):
108
+ if isinstance (info , str ):
128
109
try :
129
110
return Color (info )
130
111
except KeyError :
131
- raise ValueError ("unknown color '%s'" % info )
132
- else :
133
- r , g , b = base
134
- # We don't want to lose the data when we split it into its respective components.
135
- if not r :
136
- r = 1e-5
137
- if not g :
138
- g = 1e-5
139
- if not b :
140
- b = 1e-5
141
- return (float (info * r ), float (info * g ), float (info * b ))
112
+ raise ValueError (f"unknown color '{ info } '" )
113
+
114
+ r , g , b = base
115
+ # We don't want to lose the data when we split it into its
116
+ # respective components.
117
+ if not r :
118
+ r = 1e-5
119
+ if not g :
120
+ g = 1e-5
121
+ if not b :
122
+ b = 1e-5
123
+ return (float (info * r ), float (info * g ), float (info * b ))
142
124
143
125
144
126
class Texture (WithEqualityById , SageObject , metaclass = ClasscallMetaclass ):
@@ -278,7 +260,7 @@ def __classcall__(cls, id=None, **kwds):
278
260
return typecall (cls , id , ** kwds )
279
261
280
262
def __init__ (self , id , color = (.4 , .4 , 1 ), opacity = 1 , ambient = 0.5 ,
281
- diffuse = 1 , specular = 0 , shininess = 1 , name = None , ** kwds ):
263
+ diffuse = 1 , specular = 0 , shininess = 1 , name = None , ** kwds ) -> None :
282
264
r"""
283
265
Construction of a texture.
284
266
@@ -321,7 +303,7 @@ def __init__(self, id, color=(.4, .4, 1), opacity=1, ambient=0.5,
321
303
specular = parse_color (specular , color )
322
304
self .specular = specular
323
305
324
- def _repr_ (self ):
306
+ def _repr_ (self ) -> str :
325
307
"""
326
308
Return a string representation of the Texture object.
327
309
@@ -338,7 +320,7 @@ def _repr_(self):
338
320
else :
339
321
return f"Texture({ self .id } , { self .hex_rgb ()} )"
340
322
341
- def hex_rgb (self ):
323
+ def hex_rgb (self ) -> str :
342
324
"""
343
325
EXAMPLES::
344
326
@@ -350,7 +332,7 @@ def hex_rgb(self):
350
332
"""
351
333
return "{:02x}{:02x}{:02x}" .format (* tuple (int (255 * s ) for s in self .color ))
352
334
353
- def tachyon_str (self ):
335
+ def tachyon_str (self ) -> str :
354
336
r"""
355
337
Convert Texture object to string suitable for Tachyon ray tracer.
356
338
@@ -383,7 +365,7 @@ def tachyon_str(self):
383
365
diffuse = diffuse , specular = specular ,
384
366
opacity = self .opacity , color = self .color )
385
367
386
- def x3d_str (self ):
368
+ def x3d_str (self ) -> str :
387
369
r"""
388
370
Convert Texture object to string suitable for x3d.
389
371
@@ -402,7 +384,7 @@ def x3d_str(self):
402
384
"</Appearance>" ).format (color = self .color , shininess = self .shininess ,
403
385
specular = self .specular [0 ])
404
386
405
- def mtl_str (self ):
387
+ def mtl_str (self ) -> str :
406
388
r"""
407
389
Convert Texture object to string suitable for mtl output.
408
390
@@ -426,7 +408,7 @@ def mtl_str(self):
426
408
illumination = (2 if sum (self .specular ) > 0 else 1 ),
427
409
shininess = self .shininess , opacity = self .opacity )
428
410
429
- def jmol_str (self , obj ):
411
+ def jmol_str (self , obj ) -> str :
430
412
r"""
431
413
Convert Texture object to string suitable for Jmol applet.
432
414
0 commit comments