Ticket #9234: trac_9234-reviewer.patch

File trac_9234-reviewer.patch, 7.9 KB (added by kcrisman, 10 years ago)

Apply after initial patch

  • doc/en/reference/plot3d.rst

    # HG changeset patch
    # User Karl-Dieter Crisman <kcrisman@gmail.com>
    # Date 1276889421 14400
    # Node ID e4a63e320dc568fada99acb40f801991712893c1
    # Parent  d74a53c1a6481215529757f1dacd88c145616370
    Trac 9234 - small additions to doc coverage of texture.py, put in reference manual.
    
    diff -r d74a53c1a648 -r e4a63e320dc5 doc/en/reference/plot3d.rst
    a b  
    1515   sage/plot/plot3d/shapes2
    1616   sage/plot/plot3d/base
    1717   sage/plot/plot3d/tachyon
     18   sage/plot/plot3d/texture
  • sage/plot/plot3d/texture.py

    diff -r d74a53c1a648 -r e4a63e320dc5 sage/plot/plot3d/texture.py
    a b  
    11r"""
    2 Texture/material support for 3D Graphics objects and plotting.
    3 This is a very rough common interface for Tachyon, x3d, and obj (mtl).
     2Texture Support
     3
     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
     8:class:`Texture_class <sage.plot.plot3d.texture.Texture_class>`
     9for full details about options and use.
     10
     11Initially, we have no textures set::
     12
     13    sage: sage.plot.plot3d.base.Graphics3d().texture_set()
     14    set([])
     15
     16However, one can access these textures in the following manner::
     17
     18    sage: G = tetrahedron(color='red') + tetrahedron(color='yellow') + tetrahedron(color='red', opacity=0.5)
     19    sage: [t for t in G.texture_set() if t.color == colors.red] # we should have two red textures
     20    [Texture(texture..., red, ff0000), Texture(texture..., red, ff0000)]
     21    sage: [t for t in G.texture_set() if t.color == colors.yellow] # ...and one yellow
     22    [Texture(texture..., yellow, ffff00)]
     23
     24And the Texture objects keep track of all their data::
     25
     26    sage: T = tetrahedron(color='red', opacity=0.5)
     27    sage: t = T.get_texture()
     28    sage: t.opacity
     29    0.500000000000000
     30    sage: T # should be translucent
    431
    532AUTHOR:
    6     -- Robert Bradshaw (2007-07-07) Initial version.
     33
     34- Robert Bradshaw (2007-07-07) Initial version.
    735   
    836"""
    937from sage.structure.sage_object import SageObject
     
    1745
    1846def is_Texture(x):
    1947    r"""
    20     Return whether x is an instance of ``Texture_class``.
     48    Return whether ``x`` is an instance of ``Texture_class``.
    2149
    2250    EXAMPLES::
    2351
     
    3967
    4068    INPUT:
    4169
    42     - ``id`` - a texture (optional, default: None), a dict, a color, an
     70    - ``id`` - a texture (optional, default: None), a dict, a color, a
    4371      str, a tuple, None or any other type acting as an ID. If ``id`` is
    4472      None, then it returns a unique texture object.
    4573    - ``texture`` - a texture
     
    5482
    5583    OUTPUT:
    5684
    57     a texture object
     85    A texture object.
    5886
    5987    EXAMPLES:
    6088
    61     Texture from integer id::
     89    Texture from integer ``id``::
    6290
    6391        sage: from sage.plot.plot3d.texture import Texture
    6492        sage: Texture(17)
    6593        Texture(17, 6666ff)
    6694
    67     Texture from rational id::
     95    Texture from rational ``id``::
    6896
    6997        sage: Texture(3/4)
    7098        Texture(3/4, 6666ff)
    7199
    72     Texture from dict::
     100    Texture from a dict::
    73101
    74102        sage: Texture({'color':'orange','opacity':0.5})
    75103        Texture(texture..., orange, ffa500)
     
    80108        sage: Texture(c)
    81109        Texture(texture..., ff0000)
    82110
    83     Texture from a valid str color::
     111    Texture from a valid string color::
    84112
    85113        sage: Texture('red')
    86114        Texture(texture..., red, ff0000)
    87115
    88     Texture from a non valid str color::
     116    Texture from a non valid string color::
    89117
    90118        sage: Texture('redd')
    91119        Texture(redd, 6666ff)
     
    95123        sage: Texture((.2,.3,.4))
    96124        Texture(texture..., 334c66)
    97125
    98     Texture using other keywords::
     126    Textures using other keywords::
    99127
    100128        sage: Texture(specular=0.4)
    101129        Texture(texture..., 6666ff)
     
    137165   
    138166def parse_color(info, base=None):
    139167    r"""
    140     Parse the color.
     168    Parses the color.
    141169   
    142     It transforms valid color str into color object and
    143     color object into tuple of length 3. Otherwise, it multiplies the info
    144     by the base color.
     170    It transforms a valid color string into a color object and
     171    a color object into an RBG tuple of length 3. Otherwise,
     172    it multiplies the info by the base color.
    145173
    146174    INPUT:
    147175
     
    150178
    151179    OUTPUT:
    152180
    153     tuple or color
     181    A tuple or color.
    154182
    155183    EXAMPLES:
    156184
     
    188216            raise ValueError, "unknown color '%s'"%info
    189217    else:
    190218        r, g, b = base
    191         # We don't want to loose the data when we split it into its respective components.
     219        # We don't want to lose the data when we split it into its respective components.
    192220        if not r: r = 1e-5
    193221        if not g: g = 1e-5
    194222        if not b: b = 1e-5
     
    199227    r"""
    200228    Construction of a texture.
    201229   
    202     See documentation of ``Texture`` for more details and examples.
     230    See documentation of :meth:`Texture <sage.plot.plot3d.texture.Texture>` for more details and examples.
    203231
    204232    EXAMPLES:
    205233
     
    214242        sage: t.jmol_str('obj')
    215243        'color obj translucent 0.4 [102,102,255]'
    216244        sage: t.mtl_str()
    217         'newmtl texture23\nKa 0.2 0.2 0.5\nKd 0.4 0.4 1.0\nKs 0.0 0.0 0.0\nillum 1\nNs 1\nd 0.600000000000000'
     245        'newmtl texture44\nKa 0.2 0.2 0.5\nKd 0.4 0.4 1.0\nKs 0.0 0.0 0.0\nillum 1\nNs 1\nd 0.600000000000000'
    218246        sage: t.x3d_str()
    219247        "<Appearance><Material diffuseColor='0.4 0.4 1.0' shininess='1' specularColor='0.0 0.0 0.0'/></Appearance>"
    220248    """
     
    222250        r"""
    223251        Construction of a texture.
    224252       
    225         See documentation of ``Texture`` for more details and examples.
     253        See documentation of :meth:`Texture <sage.plot.plot3d.texture.Texture>` for more details and examples.
    226254
    227255        EXAMPLES::
    228256
     
    260288       
    261289    def _repr_(self):
    262290        """
     291        Gives string representation of the Texture object.
     292
    263293        EXAMPLES::
    264294       
    265295            sage: from sage.plot.plot3d.texture import Texture
     
    287317       
    288318    def tachyon_str(self):
    289319        r"""
     320        Converts Texture object to string suitable for Tachyon ray tracer.
     321
    290322        EXAMPLES::
    291323
    292324            sage: from sage.plot.plot3d.texture import Texture
    293325            sage: t = Texture(opacity=0.6)
    294326            sage: t.tachyon_str()
    295             'Texdef texture28\n  Ambient 0.333333333333 Diffuse 0.666666666667 Specular 0.0 Opacity 0.600000000000000\n   Color 0.4 0.4 1.0\n   TexFunc 0'
     327            'Texdef texture49\n  Ambient 0.333333333333 Diffuse 0.666666666667 Specular 0.0 Opacity 0.600000000000000\n   Color 0.4 0.4 1.0\n   TexFunc 0'
    296328        """
    297329        total_color = float(sum(self.ambient) + sum(self.diffuse) + sum(self.specular))
    298330        if total_color == 0:
     
    308340
    309341    def x3d_str(self):
    310342        r"""
     343        Converts Texture object to string suitable for x3d.
     344
    311345        EXAMPLES::
    312346
    313347            sage: from sage.plot.plot3d.texture import Texture
     
    320354               
    321355    def mtl_str(self):
    322356        r"""
     357        Converts Texture object to string suitable for mtl output.
     358
    323359        EXAMPLES::
    324360
    325361            sage: from sage.plot.plot3d.texture import Texture
    326362            sage: t = Texture(opacity=0.6)
    327363            sage: t.mtl_str()
    328             'newmtl texture2\nKa 0.2 0.2 0.5\nKd 0.4 0.4 1.0\nKs 0.0 0.0 0.0\nillum 1\nNs 1\nd 0.600000000000000'
     364            'newmtl texture23\nKa 0.2 0.2 0.5\nKd 0.4 0.4 1.0\nKs 0.0 0.0 0.0\nillum 1\nNs 1\nd 0.600000000000000'
    329365        """
    330366        return "\n".join(["newmtl %s" % self.id,
    331367                   "Ka %s %s %s" % self.ambient,
     
    337373
    338374    def jmol_str(self, obj):
    339375        r"""
     376        Converts Texture object to string suitable for Jmol applet.
     377
    340378        INPUT:
    341379
    342380        - ``obj`` - str