chiark / gitweb /
overflow-tube: wip cut2 (whitespace)
[quacks.git] / Quacks.pm
index 11cfe1356bf814cecd6c23062e0de6e49c262551..b4b06dcf12965bcabd7c4e7613f494c884d7ec99 100644 (file)
--- a/Quacks.pm
+++ b/Quacks.pm
@@ -17,7 +17,7 @@ our @EXPORT = qw(
 
  $page_pre ps_start
 
- arrow_any
+ arrow_any chip ruby
 
               );
 
@@ -65,6 +65,52 @@ sub arrow_any ($) { <<END;
 END
 };
 
+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 //= '';