Initialize Tizen 2.3
[framework/graphics/cairo.git] / util / cairo-script / examples / dragon.cs
1 %!CairoScript
2 /pot { % n -- n
3   1 sub
4   dup  -1 bitshift or
5   dup  -2 bitshift or
6   dup  -4 bitshift or
7   dup  -8 bitshift or
8   dup -16 bitshift or
9   1 add
10 } bind def
11
12 /direction { % i -- bool
13   dup 2 lt { pop true } {
14       dup 1 add dup pot dup 3 -1 roll eq { pop pop true } {
15           2 div 1 sub 2 mul exch sub direction not
16       } ifelse
17   } ifelse
18 } bind def
19
20 /path { % cr dx dy -- cr
21   0 1 2048 {
22     4 1 roll 3 copy L pop 4 -1 roll direction {
23       exch neg
24     } {
25       neg exch
26     } ifelse
27   } for
28   pop pop
29 } bind def
30
31 dict
32   /width  512 set
33   /height 512 set
34   surface context
35
36 1 g set-source paint
37
38 //LINE_CAP_ROUND set-line-cap
39 //LINE_JOIN_ROUND set-line-join
40 4 set-line-width
41
42 256 256 m  12 0 path 0 0 0 rgb set-source stroke
43 256 256 m -12 0 path 1 0 0 rgb set-source stroke
44 256 256 m 0  12 path 0 1 0 rgb set-source stroke
45 256 256 m 0 -12 path 0 0 1 rgb set-source stroke
46
47 /target get (out.png) write-to-png pop
48 pop