chiark / gitweb /
break out chip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2022 12:13:45 +0000 (13:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2022 12:13:45 +0000 (13:13 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Quacks.pm
pumpkin-books.ps.pl

index 11cfe1356bf814cecd6c23062e0de6e49c262551..7ae0b2ce6528cb2b26f0bfd1711734f65a1d8f16 100644 (file)
--- a/Quacks.pm
+++ b/Quacks.pm
@@ -17,7 +17,7 @@ our @EXPORT = qw(
 
  $page_pre ps_start
 
- arrow_any
+ arrow_any chip
 
               );
 
@@ -65,6 +65,39 @@ 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 ps_start (;$) {
   my ($adj) = @_;
   $adj //= '';
index fbe71e43b00143a58030581d355d94e7fe9d1fc2..3c36472edf01c1d36a8c84e220a9676df6b7c1db 100755 (executable)
@@ -8,39 +8,6 @@ use strict;
 BEGIN { unshift @INC, '.'; }
 use Quacks;
 
-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 veepsspot ($) {
   my ($chip) = @_;
   <<END;