Defines loc T: start at loc F, go forward L, translate right R,
turn left A (defaults are all 0).
- layer KL
+ layer K[L]
K is layer kind (letters and `_', may be empty), L is a layer depth
- (digits). Controls drawing style, by selecting appropriate parts of
- the track and locs to draw, according to element selection rules.
- Default outcomes:
+ (digits, or `=' meaning current layer; default for L is `='; default
+ KL at start of file is `layer 5'). Controls drawing style, by
+ selecting appropriate parts of the track and locs to draw, according
+ to element selection rules. Default outcomes:
K L result (description) result (element letters)
any other nothing -
empty current default track RLMNasco
D+ matches L iff L>=D; D++ iff L>D; D+++ iff L>D+1 and so on; D-
matches L iff L<=D; D-- iff L<D; etc.; D= matches L iff L==D; D== iff
D-1<=L<=D+1; D=== iff D-2<=L<=D+2; etc. If D is omitted the current
- layer (from the most recent -l option) is used. N may be empty or
- `~'; the latter simply inverts the sense of the match. If C is
- omitted then `=' is assumed.
+ layer (from the most recent -l option) is used (or `5' if current
+ layer is `*'). N may be empty or `~'; the latter simply inverts the
+ sense of the match. If C is omitted then `=' is assumed. If the
+ final output layer is `*' then we pretend, for the moment, that L was
+ D.
If V is present then C must be exactly one character and it is as if
V (must be an integer) copies of C were specified.
# $ctx->{Trans}{R} # but multiply all y coords by this!
# $ctx->{Draw} # sequence of one or more chrs from uc $drawers
# # or X meaning never draw anything (eg in defobj)
+# $ctx->{Layer}{Level}
+# $ctx->{Layer}{Kind}
#
# $objs{$id}{CmdLog}
# $objs{$id}{Loc}
return ($out->{X}, $out->{Y});
}
-sub newctx () {
+sub newctx (;$) {
+ my ($ctx_save) = @_;
$ctx= {
Trans => { X => 0.0, Y => 0.0, A => 0.0, R => 1.0 },
InRunObj => ""
};
+ %{ $ctx->{Layer} }= %{ $ctx_save->{Layer} }
+ if defined $ctx_save;
}
our $defobj_save;
die "repeated defobj" if exists $objs{$id};
$defobj_save= $ctx;
$defobj_ispart= $ispart;
- newctx();
+ newctx($defobj_save);
$ctx->{CmdLog}= [ ];
$ctx->{InDefObj}= $id;
$ctx->{Draw}= 'X';
+ $ctx->{Layer}= { Level => 5, Kind => '' };
}
sub cmd_enddef {
$objs{$id}{Part}= $defobj_ispart;
$ctx= $defobj_save;
$defobj_save= undef;
+ $defobj_ispart= undef;
}
sub cmd__runobj ($) {
sub cmd_layer {
my ($kl, $k,$l, $eo,$cc);
$kl= can(\&cva_identity);
- return if $ctx->{Draw} =~ m/X/;
- $kl =~ m/^([A-Za-z_]*)(\d+)$/ or die "invalid layer spec";
+ $kl =~ m/^([A-Za-z_]*)(\d*|\=)$/ or die "invalid layer spec";
($k,$l)=($1,$2);
+ $l= $ctx->{Layer}{Level} if $l =~ m/^\=?$/;
+ $ctx->{Layer}{Kind}= $l;
+ $ctx->{Layer}{Level}= $l;
+ return if $ctx->{Draw} =~ m/X/;
if ($output_layer ne '*' && $l != $output_layer) {
$ctx->{Draw} = '';
} elsif ($k eq '') {
}
foreach $eo (@eopts) {
next unless $k =~ m/^$eo->{GlobRe}$/;
- next unless $output_layer eq '*' || &{ $eo->{LayerCheck} }($l);
+ next unless &{ $eo->{LayerCheck} }($l);
foreach $cc (split //, $eo->{DrawMods}) {
$ctx->{Draw} =~ s/$cc//ig;
$ctx->{Draw} .= $cc if $cc =~ m/[A-Z]/;
$formal= $obj->{Loc}{$formal_id};
die "unknown formal $formal_id" unless $formal;
$ctx_save= $ctx;
- newctx();
+ newctx($ctx_save);
$how *= $ctx_save->{Trans}{R};
$ctx->{Trans}{R}= $how;
$ctx->{Trans}{A}= $actual->{A} - $formal->{A}/$how;
$obj= $objs{$obj_id};
next unless $obj->{Part};
($min_x, $max_x, $min_y, $max_y) = bbox($obj->{Loc});
- newctx();
+ newctx($ctx_save);
for (;;) {
$width= $max_x - $min_x;
my ($eo, $invert, $lfn, $ccc, $sense,$limit);
$g =~ s/[?*]/\\$&/g;
$d= $output_layer if !length $d;
+ $d= 5 if $d eq '*';
$invert= length $n;
$c= '=' if !length $c;
if (length $v) {
if ($c =~ m/^[-+]/) {
$sense= ($c.'1') + 0;
$limit= ($sense * $d) + length($c) - 1;
- $lfn= sub { $_[0] * $sense >= $limit xor $invert };
+ $lfn= sub {
+ ($output_layer eq '*' ? $d
+ : $_[0]) * $sense >= $limit
+ xor $invert;
+ };
} else {
$limit= length($c) - 1;
- $lfn= sub { abs($_[0] - $d) <= $limit xor $invert };
+ $lfn= sub {
+ ($output_layer eq '*' ? 1
+ : abs($_[0] - $d) <= $limit)
+ xor $invert;
+ };
}
$ccc= '';
foreach $c (split //, $cc) {