-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (89 loc) · 2.36 KB
/
Makefile
File metadata and controls
101 lines (89 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
LOGO_SIZE = 500
LOGO_TEXT = ov
FONT_FAMILY = Zilla Slab
FONT_WEIGHT = bold
FONT_SIZE = 1000
all: html.html
html.html: logo-optimized.svg
header() { \
echo '<!DOCTYPE html>'; \
echo '<html>'; \
echo '<head>'; \
echo ' <style>'; \
echo ' body {'; \
echo ' margin: 0;'; \
echo ' }'; \
echo ' svg {'; \
echo ' background-color: goldenrod;'; \
echo ' }'; \
echo ' </style>'; \
echo '</head>'; \
echo '<body>'; \
}; \
{ header; echo; cat $<; echo; } > $@
logo-optimized.svg: config-svgo.yml logo-transformed.svg
./node_modules/.bin/svgo -o $@ --config $^
logo-transformed.svg: part-path part-max part-width part-height
svg() { \
echo "<svg width=\"$$1\" height=\"$$1\">"; \
echo " <g transform=\""; \
echo " translate("; \
echo " `offset "$$1" "$$2" "$$3"`,"; \
echo " `offset "$$1" "$$2" "$$4"`"; \
echo " )"; \
echo " scale(`scale "$$1" "$$2"`)"; \
echo " \">"; \
cat $<; \
echo " </g>"; \
echo "</svg>"; \
}; \
scale() { \
echo "$$1 / $$2" | bc -l; \
}; \
offset() { \
echo "$$1 / 2 - ( $$1 * $$3 ) / ( 2 * $$2 )" | bc -l; \
}; \
svg '$(LOGO_SIZE)' "`cat part-max`" "`cat part-width`" "`cat part-height`" > $@
part-max: part-width part-height bc-max
echo "max(`cat part-width`, `cat part-height`)" | bc -l bc-max > $@
part-path: logo-path.svg
xmllint --xpath '//*[local-name()="path"]' $< > $@
part-height: logo-path.svg
xmllint --xpath 'string(/*[local-name()="svg"]/@height)' $< > $@
part-width: logo-path.svg
xmllint --xpath 'string(/*[local-name()="svg"]/@width)' $< > $@
logo-path.svg: logo-text.svg
cp $< $@.tmp.svg
inkscape \
--verb FitCanvasToDrawing \
--verb EditSelectAll \
--verb ObjectToPath \
--verb SelectionUnGroup \
--verb SelectionUnion \
--verb FileSave \
--verb FileQuit \
$(CURDIR)/$@.tmp.svg \
;
mv $@.tmp.svg $@
logo-text.svg: Makefile
svg() { \
echo "<svg>"; \
echo " <text"; \
echo " font-family=\"$$1\""; \
echo " font-weight=\"$$2\""; \
echo " font-size=\"$$3\""; \
echo " >$$4</text>"; \
echo "</svg>"; \
}; \
svg '$(FONT_FAMILY)' '$(FONT_WEIGHT)' '$(FONT_SIZE)' '$(LOGO_TEXT)' > $@
clean:
rm -f html.html
rm -f logo-optimized.svg
rm -f logo-transformed.svg
rm -f part-height
rm -f part-max
rm -f part-path
rm -f part-width
rm -f logo-path.svg
rm -f logo-path.svg.tmp.svg
rm -f logo-text.svg