summaryrefslogtreecommitdiff
path: root/libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs
blob: 4278bf74caa700328948a1e5e785868e522dea73 (plain)
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
%!CairoScript

/hA { % cr dist lvl *hA* cr dist
  dup not { pop } {
      1 sub
      3 copy hB 0 exch L pop
      3 copy hA 0 L pop
      3 copy hA neg 0 exch L pop
      hC
  } ifelse
} bind def

/hB { % cr dist lvl *hB* cr dist
  dup not { pop } {
      1 sub
      3 copy hA 0 L pop
      3 copy hB 0 exch L pop
      3 copy hB neg 0 L pop
      hD
  } ifelse
} bind def

/hC { % cr dist lvl *hC* cr dist
  dup not { pop } {
      1 sub
      3 copy hD neg 0 L pop
      3 copy hC neg 0 exch L pop
      3 copy hC 0 L pop
      hA
  } ifelse
} bind def

/hD { % cr dist lvl *hD* cr dist
  dup not { pop } {
      1 sub
      3 copy hC neg 0 exch L pop
      3 copy hD neg 0 L pop
      3 copy hD 0 exch L pop
      hB
  } ifelse
} bind def

dict
  /width  1024 set
  /height 1024 set
  surface context

2 2 m 4 10 hA pop 1 g set-source stroke

/target get (out.png) write-to-png pop
pop