summaryrefslogtreecommitdiff
path: root/libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-10-12 12:03:23 -0500
committersanine <sanine.not@pm.me>2022-10-12 12:03:23 -0500
commit530ffd0b7d3c39757b20f00716e486b5caf89aff (patch)
tree76b35fdf57317038acf6b828871f6ae25fce2ebe /libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs
parent3dbe9332e47c143a237db12440f134caebd1cfbe (diff)
add cairo
Diffstat (limited to 'libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs')
-rw-r--r--libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs b/libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs
new file mode 100644
index 0000000..4278bf7
--- /dev/null
+++ b/libs/cairo-1.16.0/util/cairo-script/examples/hilbert.cs
@@ -0,0 +1,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