Changeset 7490:f8c7503f9520


Ignore:
Timestamp:
12/01/07 22:01:05 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Fix trac #799 -- tachyon texfunc issue -- and add some doctests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/plot/tachyon.py

    r6997 r7490  
    77    -- Joshua Kantor: 3d function plotting 
    88    -- Tom Boothby: 3d function plotting n'stuff 
     9    -- Leif Hille: key idea for bugfix for texfunc issue (trac #799) 
    910 
    1011TODO: 
     
    268269 
    269270    def texfunc(self, type=0, center=(0,0,0), rotate=(0,0,0), scale=(1,1,1)): 
     271        """ 
     272 
     273        INPUT: 
     274            type -- (default: 0) 
     275                 0: No special texture, plain shading 
     276                 1: 3D checkerboard function, like a rubik's cube 
     277                 2: Grit Texture, randomized surface color 
     278                 3: 3D marble texture, uses object's base color 
     279                 4: 3D wood texture, light and dark brown, not very good yet 
     280                 5: 3D gradient noise function (can't remember what it look like 
     281                 6: Don't remember 
     282                 7: Cylindrical Image Map, requires ppm filename   (don't know how to specify name in sage?!) 
     283                 8: Spherical Image Map, requires ppm filename     (don't know how to specify name in sage?!)   
     284                 9: Planar Image Map, requires ppm filename        (don't know how to specify name in sage?!) 
     285            center -- (default: (0,0,0)) 
     286            rotate -- (default: (0,0,0)) 
     287            scale -- (default: (1,1,1)) 
     288 
     289        EXAMPLES: 
     290        We draw an infinite checkboard: 
     291            sage: t = Tachyon(camera_center=(2,7,4), look_at=(2,0,0)) 
     292            sage: t.texture('black', color=(0,0,0), texfunc=1) 
     293            sage: t.plane((0,0,0),(0,0,1),'black') 
     294            sage: t.show() 
     295        """ 
    270296        return Texfunc(type,center,rotate,scale).str() 
    271297 
     
    273299                specular=0.0, opacity=1.0, 
    274300                color=(1.0,0.0, 0.5), texfunc=0, phong=0, phongsize=.5, phongtype="PLASTIC"): 
     301        """ 
     302        INPUT: 
     303            name -- string; the name of the texture (to be used later) 
     304            ambient -- (default: 0.2) 
     305            diffuse -- (default: 0.8) 
     306            specular -- (default: 0.0) 
     307            opacity -- (default: 1.0) 
     308            color -- (default: (1.0,0.0,0.5)) 
     309            texfunc -- (default: 0); a texture function; this is either the output of 
     310                       self.texfunc, or a number between 0 and 9, inclusive.  See 
     311                       the docs for self.texfunc. 
     312            phong -- (default: 0) 
     313            phongsize -- (default: 0.5) 
     314            phongtype -- (default: "PLASTIC") 
     315         
     316        EXAMPLES: 
     317        We draw a scene with 4 sphere that illustrates various uses of the texture command: 
     318            sage: t = Tachyon(camera_center=(2,5,4), look_at=(2,0,0), raydepth=6) 
     319            sage: t.light((10,3,4), 1, (1,1,1)) 
     320            sage: t.texture('mirror', ambient=0.05, diffuse=0.05, specular=.9, opacity=0.9, color=(.8,.8,.8)) 
     321            sage: t.texture('grey', color=(.8,.8,.8), texfunc=3) 
     322            sage: t.plane((0,0,0),(0,0,1),'grey') 
     323            sage: t.sphere((4,-1,1), 1, 'mirror') 
     324            sage: t.sphere((0,-1,1), 1, 'mirror') 
     325            sage: t.sphere((2,-1,1), 0.5, 'mirror') 
     326            sage: t.sphere((2,1,1), 0.5, 'mirror') 
     327            sage: show(t)         
     328        """ 
     329        if texfunc and not isinstance(texfunc, Texfunc): 
     330            texfunc = self.texfunc(int(texfunc)) 
    275331        self._objects.append(Texture(name, ambient, diffuse, 
    276332                                     specular, opacity, color, texfunc, 
Note: See TracChangeset for help on using the changeset viewer.