chiark / gitweb /
Pumpkin values in md file
[quacks.git] / Quacks.pm
index 9583c9bd290656e4a85f016caad289aeadf8d559..b4b06dcf12965bcabd7c4e7613f494c884d7ec99 100644 (file)
--- a/Quacks.pm
+++ b/Quacks.pm
@@ -15,9 +15,9 @@ our @EXPORT = qw(
 
  $ps_framing
 
- $page_pre ps_head
+ $page_pre ps_start
 
- arrow_any
+ arrow_any chip ruby
 
               );
 
@@ -49,12 +49,7 @@ sub colour ($) {
 our $anychip = ['0.8', '0'];
 our $black = colour('0');
 
-our $page_pre = <<END;
-72 25.4 div dup scale
-%210 0 translate
-%90 rotate
-7 30 translate
-END
+our $page_pre;
 
 our $ps_framing = '';
 
@@ -70,7 +65,63 @@ sub arrow_any ($) { <<END;
 END
 };
 
-sub ps_head () {
+sub chip ($$) {
+  my ($cary, $pips) = @_; # put in a gsave translate
+  my $o = <<END;
+  newpath
+  0 0 chip 0.5 mul 0 360 arc
+  gsave 1 setlinewidth $black stroke grestore
+  ${\ colour($cary->[0]) } fill
+END
+  if ($pips) {
+    $o .= <<END;
+  ${\ colour($cary->[1]) }
+END
+  }
+  my $spot = sub {
+    my ($x,$y) = @_;
+    $o .= <<END;
+    newpath
+    spot 0.5 sqrt mul 1.1 mul dup
+    $x mul exch $y mul
+    spot 0.5 mul
+    0 360 arc fill
+END
+  };
+
+  $spot->( 0, 0) if $pips & 1;
+  $spot->(-1,-1) if $pips & 6;
+  $spot->(+1,+1) if $pips & 6;
+  $spot->(-1,+1) if $pips & 4;
+  $spot->(+1,-1) if $pips & 4;
+
+  $o;
+}
+
+sub ruby () { # put in gsave translate
+  <<END;
+  newpath
+    rubysz neg  0 moveto
+    0  rubysz neg lineto
+    rubysz      0 lineto
+    0      rubysz lineto
+    closepath
+    ${\ colour('1 .2 .2') } gsave fill grestore
+    $black 1 setlinewidth stroke
+END
+}
+
+sub ps_start (;$) {
+  my ($adj) = @_;
+  $adj //= '';
+
+  $page_pre = <<END;
+72 25.4 div dup scale
+%210 0 translate
+%90 rotate
+$adj
+END
+
   $ps_framing .= <<END;
 %!