summaryrefslogtreecommitdiff
path: root/libs/cairo-1.16.0/util/cairo-script/examples/sierpinski.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/sierpinski.cs
parent3dbe9332e47c143a237db12440f134caebd1cfbe (diff)
add cairo
Diffstat (limited to 'libs/cairo-1.16.0/util/cairo-script/examples/sierpinski.cs')
-rw-r--r--libs/cairo-1.16.0/util/cairo-script/examples/sierpinski.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/libs/cairo-1.16.0/util/cairo-script/examples/sierpinski.cs b/libs/cairo-1.16.0/util/cairo-script/examples/sierpinski.cs
new file mode 100644
index 0000000..6f95908
--- /dev/null
+++ b/libs/cairo-1.16.0/util/cairo-script/examples/sierpinski.cs
@@ -0,0 +1,37 @@
+%!CairoScript
+
+/1sqrt3 0.577359269 def
+
+/T { % cr size -- cr
+ exch % size cr
+ 0 0 m 1 index 0 l 1 index dup 2 div exch //1sqrt3 mul l h
+
+ exch 2 div
+ dup 4 ge {
+ exch % size/2 cr
+
+ 1 index T
+ save 1 index 0 translate 1 index T restore
+ save 1 index dup 2 div exch //1sqrt3 mul translate 1 index T restore
+
+ exch
+ } if
+ pop
+} bind def
+
+dict
+ /width 512 set
+ /height 300 set
+ surface context
+
+1 1 1 set-source-rgb paint
+
+.5 set-line-width
+
+0 300 translate
+1 -1 scale
+
+512 T 0 0 0 set-source-rgb stroke
+
+/target get (out.png) write-to-png pop
+pop