File: sci_colordef.sci

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (79 lines) | stat: -rw-r--r-- 2,346 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function [tree]=sci_colordef(tree)
// Copyright INRIA
// M2SCI function
// Conversion function for Matlab colordef()
// Input: tree = Matlab funcall tree
// Ouput: tree = Scilab equivalent for tree
// V.C.

if tree.lhs(1).name=="ans" then
  f=gettempvar()
else  
  f=tree.lhs(1)
end

// colordef color_option
if rhs==1 then
  if typeof(tree.rhs(1))=="cste" then
    if or(tree.rhs(1).value==["black","none"]) then
      insert(Equal(list(f),Funcall("gcf",1,list(),list())))
      LHS=Operation("ins",list(f,Cste("background")),list())
      insert(Equal(list(LHS),Cste(-1)))
      tree=list()
    elseif tree.rhs(1).value=="white" then
      insert(Equal(list(f),Funcall("gcf",1,list(),list())))
      LHS=Operation("ins",list(f,Cste("background")),list())
      insert(Equal(list(LHS),Cste(-2)))
      tree=list()
    else
      no_equiv(expression2code(tree))
    end
  else
    tree.name="mtlb_colordef"
  end
else
  // colordef('new',color_opt)
  if tree.rhs(1).vtype==String then
    winsid_funcall=Funcall("winsid",1,list(),list())
    max_funcall=Funcall("max",1,list(winsid_funcall),list())
    addition=Operation("+",list(max_funcall,Cste(1)),list())
    scf_funcall=Funcall("scf",1,list(addition),list())
    insert(Equal(list(f),scf_funcall))
    if or(tree.rhs(2).value==["black","none"]) then
      LHS=Operation("ins",list(f,Cste("background")),list())
      insert(Equal(list(LHS),Cste(-1)))
      tree=list()
    elseif tree.rhs(2).value=="white" then
      LHS=Operation("ins",list(f,Cste("background")),list())
      insert(Equal(list(LHS),Cste(-2)))
      tree=list()
    else
      no_equiv(expression2code(tree))
    end
    
// colordef(fig,color_opt)
elseif tree.rhs(1).vtype==Handle then
    f=tree.rhs(1)
    if or(tree.rhs(2).value==["black","none"]) then
      LHS=Operation("ins",list(f,Cste("background")),list())
      insert(Equal(list(LHS),Cste(-1)))
      if tree.lhs(1).name<>"ans" then
	insert(Equal(list(tree.lhs(1)),f))
      end
      tree=list()
    elseif tree.rhs(2).value=="white" then
      LHS=Operation("ins",list(f,Cste("background")),list())
      insert(Equal(list(LHS),Cste(-2)))
      if tree.lhs(1).name<>"ans" then
	insert(Equal(list(tree.lhs(1)),f))
      end
      tree=list()
    else
      no_equiv(expression2code(tree))
    end
  else
    tree.name="mtlb_colordef"
  end
end

endfunction