File: 51%20-%20switch%20example.txt

package info (click to toggle)
povray 1%3A3.7.0.8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 146,780 kB
  • sloc: cpp: 845,005; ansic: 122,118; sh: 34,206; pascal: 6,420; asm: 3,355; ada: 1,681; makefile: 1,387; cs: 879; awk: 590; perl: 245; xml: 95
file content (27 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (7)
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
// Let's make some constant names
#declare CS_Medium = 1;
#declare CS_Hard = 3;
#declare CS_Easy = 5;

// Let the user choose the method to use
#declare Complexity_Switch = CS_Medium; // or CS_Easy or CS_Hard

// Do something dependent on the user's choice
#switch (Complexity_Switch)

  #case (CS_Easy)
    // This statement is done if Complexity_Switch is CS_Easy
    #declare MyShape = box { -<1, 1, 1>, <1, 1, 1> }
  #break // End of this case section

  #range (CS_Medium, CS_Hard)
    // This statement is done if Complexity_Switch is CS_Medium
    // or CS_Hard or anything in between
    #declare MyShape = torus { 1, 0.5 }
  #break // End of this range section

  #else
    // This statement is done if none of the above match
    #declare MyShape = sphere { <0, 0, 0>, 1 }

#end // End of switch statement