From 530ffd0b7d3c39757b20f00716e486b5caf89aff Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 12 Oct 2022 12:03:23 -0500 Subject: add cairo --- .../util/cairo-script/examples/dragon.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 libs/cairo-1.16.0/util/cairo-script/examples/dragon.cs (limited to 'libs/cairo-1.16.0/util/cairo-script/examples/dragon.cs') diff --git a/libs/cairo-1.16.0/util/cairo-script/examples/dragon.cs b/libs/cairo-1.16.0/util/cairo-script/examples/dragon.cs new file mode 100644 index 0000000..1060ca6 --- /dev/null +++ b/libs/cairo-1.16.0/util/cairo-script/examples/dragon.cs @@ -0,0 +1,48 @@ +%!CairoScript +/pot { % n -- n + 1 sub + dup -1 bitshift or + dup -2 bitshift or + dup -4 bitshift or + dup -8 bitshift or + dup -16 bitshift or + 1 add +} bind def + +/direction { % i -- bool + dup 2 lt { pop true } { + dup 1 add dup pot dup 3 -1 roll eq { pop pop true } { + 2 div 1 sub 2 mul exch sub direction not + } ifelse + } ifelse +} bind def + +/path { % cr dx dy -- cr + 0 1 2048 { + 4 1 roll 3 copy L pop 4 -1 roll direction { + exch neg + } { + neg exch + } ifelse + } for + pop pop +} bind def + +dict + /width 512 set + /height 512 set + surface context + +1 g set-source paint + +//LINE_CAP_ROUND set-line-cap +//LINE_JOIN_ROUND set-line-join +4 set-line-width + +256 256 m 12 0 path 0 0 0 rgb set-source stroke +256 256 m -12 0 path 1 0 0 rgb set-source stroke +256 256 m 0 12 path 0 1 0 rgb set-source stroke +256 256 m 0 -12 path 0 0 1 rgb set-source stroke + +/target get (out.png) write-to-png pop +pop -- cgit v1.2.1