1
function [tree]=sci_colordef(tree)
4
// Conversion function for Matlab colordef()
5
// Input: tree = Matlab funcall tree
6
// Ouput: tree = Scilab equivalent for tree
9
if tree.lhs(1).name=="ans" then
15
// colordef color_option
17
if typeof(tree.rhs(1))=="cste" then
18
if or(tree.rhs(1).value==["black","none"]) then
19
insert(Equal(list(f),Funcall("gcf",1,list(),list())))
20
LHS=Operation("ins",list(f,Cste("background")),list())
21
insert(Equal(list(LHS),Cste(-1)))
23
elseif tree.rhs(1).value=="white" then
24
insert(Equal(list(f),Funcall("gcf",1,list(),list())))
25
LHS=Operation("ins",list(f,Cste("background")),list())
26
insert(Equal(list(LHS),Cste(-2)))
29
no_equiv(expression2code(tree))
32
tree.name="mtlb_colordef"
35
// colordef('new',color_opt)
36
if tree.rhs(1).vtype==String then
37
winsid_funcall=Funcall("winsid",1,list(),list())
38
max_funcall=Funcall("max",1,list(winsid_funcall),list())
39
addition=Operation("+",list(max_funcall,Cste(1)),list())
40
scf_funcall=Funcall("scf",1,list(addition),list())
41
insert(Equal(list(f),scf_funcall))
42
if or(tree.rhs(2).value==["black","none"]) then
43
LHS=Operation("ins",list(f,Cste("background")),list())
44
insert(Equal(list(LHS),Cste(-1)))
46
elseif tree.rhs(2).value=="white" then
47
LHS=Operation("ins",list(f,Cste("background")),list())
48
insert(Equal(list(LHS),Cste(-2)))
51
no_equiv(expression2code(tree))
54
// colordef(fig,color_opt)
55
elseif tree.rhs(1).vtype==Handle then
57
if or(tree.rhs(2).value==["black","none"]) then
58
LHS=Operation("ins",list(f,Cste("background")),list())
59
insert(Equal(list(LHS),Cste(-1)))
60
if tree.lhs(1).name<>"ans" then
61
insert(Equal(list(tree.lhs(1)),f))
64
elseif tree.rhs(2).value=="white" then
65
LHS=Operation("ins",list(f,Cste("background")),list())
66
insert(Equal(list(LHS),Cste(-2)))
67
if tree.lhs(1).name<>"ans" then
68
insert(Equal(list(tree.lhs(1)),f))
72
no_equiv(expression2code(tree))
75
tree.name="mtlb_colordef"