Closed williamstein closed 16 years ago
From Leif Hille
I dunno if this is the right way to comment on bugs however, I ran into the same problem as the ticket's author. This "bug" ticket is part bug, part user error (or poor documentation).
(1) The user error part: In order to create a texture using a number other than zero, you have to pass in a .texfunc() object.
(2) The bug part: There is a problem with the plot/tachyon.py function that prevents additional key parameters from being passed in.
Explanation:
t.texture('grey', color=(.5,.5,.5), texfunc=0) --> this works
t.texture('dk_grey', color=(0.8,0.8,0.8),textfunc=1) --> this causes subsequent t.show() command to fail.
Solution:
(1) While the t.texture(...) function allows for 'texfunc=0' as an argument, for any number greater than 0, it expects a texfunc object.
ie:
r=t.texfunc(2)
t.texture('grey', color=(.5,.5,.5), texfunc=r)
This is not evident from the inline help & the interface doesn't complain when it's passed bad input - it just fails when t.show() is called (verbose mode reveals the tachyon parser's complaints).
(2) The bug is that some of the predefined numbered textures require additional string input (eg. a file name for a texture map image/data) immediately after the texture number. The texture number is passed in as a number. I've made a workaround, making the "type" parameter into a string(see changes below), allowing for filenames to be specified when the texture number calls for it. This is still a little troublesome in that because it's not obvious to me how to reference filenames of graphics created within Sage (maybe there should there be a toplevel "fileref" method to get a filesystem path reference to existing graphic image or dataset). The same filereference problem presents if the user wants to use another graphic or datafile as a texture map.
##from : .../plot/tachyon.py...
class Texfunc:
def __init__(self, type=0,center=(0,0,0), rotate=(0,0,0), scale=(1,1,1)):
self._type = type
self._center = center
self._rotate = rotate
self._scale = scale
def str(self):
if type == 0:
return "0"
# Old Code
# return """%d center %s rotate %s scale %s"""%(self._type, # <-- number
# >tostr(self._center),
# >tostr(self._rotate),
# tostr(self._scale))
# new code:
return """%s center %s rotate %s scale %s"""%(tostr(self._type), # <-- string
>tostr(self._center),
>tostr(self._rotate),
tostr(self._scale))
Attachment: trac799-part1.patch.gz
Attachment: trac799-part2.patch.gz
These patches are definitely an improvement, and should go in.
There's still some more work to be done (documentation at least, perhaps some code too) to be able to use the full power of tachyon (like texture maps); but that can wait for later.
Merged in 2.8.15.alpha2.
Many thanks for your bug report.
By the way, even if it is a Tachyon bug, we really want to know about it, so we can program around it and/or fix it.
William
Component: packages: standard
Issue created by migration from https://trac.sagemath.org/ticket/799