chiark / gitweb /
dice: d6: image: wip extraction
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 23:35:37 +0000 (00:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 12 May 2022 01:04:48 +0000 (02:04 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
Makefile
dice/extract-image-only [new file with mode: 0755]

index d9e68d79aedec074a056ed2fa4d243fa19a8b310..9bd49f24bfbdf0d86a8b5aca80d836d597947f2c 100644 (file)
@@ -15,6 +15,7 @@ save/lock
 /library/*/files.make
 /library/*/*.usvg
 /library/*/*.coloured.svg
+/library/edited/dice-d6-blue.svg
 *.tmp
 .tsconfig.*.json
 stamp/*
index 45c8f096e392f7f78a108e95e707c1cd7c01b5fd..98dd904ca01946fe8f78ec253d9971d43cb2a1a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -380,6 +380,9 @@ templates/shapelib.html: $(TARGET_DIR)/debug/otterlib $(LIBRARY_FILES)
 nwtemplates/die-overlay.tera: dice/overlay-template-extractor dice/die.svg
        ./$< <dice/die.svg >$@.tmp && mv -f $@.tmp $@
 
+library/edited/dice-d6-blue.svg: dice/extract-image-only dice/die.svg
+       ./$< <dice/die.svg >$@.tmp && mv -f $@.tmp $@
+
 #---------- examples ----------
 
 EXAMPLE_BUNDLE_INPUT_DEPS := $(shell                                   \
diff --git a/dice/extract-image-only b/dice/extract-image-only
new file mode 100755 (executable)
index 0000000..5a9ddb9
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl -w
+use strict;
+
+use strict;
+
+use XML::LibXML;
+use XML::LibXML::XPathContext;
+
+use Data::Dumper;
+
+my $dom = XML::LibXML->load_xml(IO => \*STDIN) or die;
+
+print "<!--made by dice/extract-image-only-->\n" or die $!;
+
+my $nodes = $dom->findnodes('//*[@inkscape:label]');
+foreach my $node (@$nodes) {
+  my $l = $node->getAttribute('inkscape:label');
+  next unless $l =~ m/^time|^text/;
+  my $parent = $node->parentNode;
+  $parent->removeChild($node);
+}
+
+print $dom->toString or die $!;