-
Notifications
You must be signed in to change notification settings - Fork 18
/
example-glyph-image-maker.html
150 lines (136 loc) · 6.62 KB
/
example-glyph-image-maker.html
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="ja" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="black.css" />
<script type="text/javascript" src="glyph-tools.js" charset="utf-8"></script>
<script type="text/javascript" src="glyph-dic.js" charset="utf-8"></script>
<title>Glyph Image Maker - Ingress Glyph Tools</title>
<!-- for webapp support -->
<link rel="apple-touch-icon" sizes="180x180" href="webapp-resources/apple-touch-icon.png" />
<link rel="icon" type="image/png" href="webapp-resources/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="webapp-resources/favicon-16x16.png" sizes="16x16" />
<link rel="manifest" href="webapp-manifest.json" />
<link rel="mask-icon" href="webapp-resources/safari-pinned-tab.svg" color="#5bbad5" />
<link rel="shortcut icon" href="webapp-resources/favicon.ico" />
<meta name="apple-mobile-web-app-title" content="Ingress Glyph Tools" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="application-name" content="Ingress Glyph Tools" />
<meta name="msapplication-config" content="webapp-browserconfig.xml" />
<meta name="theme-color" content="#ffffff" />
<script type="text/javascript" src="webapp-resources/common.js" charset="utf-8"></script>
</head>
<body>
<a href="index.html">Ingress Glyph Tools</a>
<!-- Glyph Input -->
<div id="glyph-pad">
</div>
<div id="control">
<input type="button" value="Clear" onclick="glyphPad.clearGlyph()" />
<input type="button" value="Undo" onclick="glyphPad.removeLastEdge()" />
</div>
Glyph name:<input type="text" id="glyph-word" /><input type="button" value="Set" onclick="setGlyphFromWord(ID('glyph-word').value)" /><br />
<!-- Image Options -->
<form id="glyph-options">
Size:<input id="glyph-size" type="number" value="128" style="width: 4em;" />
<!-- Glyph Line -->
<div>
<label><input id="glyph-visible" type="checkbox" checked="checked" />Glyph Line</label>
<input id="glyph-color" type="color" value="#40ebcd" />
Line Width:<input id="glyph-line-width" type="number" value="5" style="width: 3em;" />
Diameter:<input id="glyph-diameter" type="number" step="0.01" value="0.74" style="width: 4em;"/>
</div>
<!-- Hex Border -->
<div>
<label><input id="hexagon-visible" type="checkbox" checked="checked" />Hex Border</label>
<input id="hexagon-color" type="color" value="#40ebcd" />
Line Width:<input id="hexagon-line-width" type="number" value="5" style="width: 3em;"/>
<label><input id="hexagon-fill-enabled" type="checkbox" checked="checked" />Fill</label>
<input id="hexagon-fill-color" type="color" value="#105050"/>
Diameter:<input id="hexagon-diameter" type="number" step="0.01" value="0.94" style="width: 5em;" />
</div>
<!-- Grid -->
<div>
<label><input id="grid-visible" type="checkbox" checked="checked" />Grid</label>
<input id="grid-color" type="color" value="#ffffff" />
Line Width:<input id="grid-line-width" type="number" value="0" style="width: 3em;" />
<label><input id="grid-fill-enabled" type="checkbox" checked="checked" />Fill</label>
<input id="grid-fill-color" type="color" value="#f0f020" />
Node Radius:<input id="grid-node-radius" type="number" value="3" style="width: 3em;" />
</div>
<!-- -->
<label><input id="glyph-svg" type="checkbox" />Output SVG</label><br />
<input id="reset-button" type="button" value="Reset Options" />
</form>
<!-- Result -->
<div id="result">
<div id="glyph-element"></div>
<textarea id="glyph-text"></textarea>
</div>
<script>
var gm9igt = gm9.IngressGlyphTools;
function ID(id){return document.getElementById(id);}
var glyphPad = gm9igt.createInputPad({size:300, style:{color:"white"}});
ID("glyph-pad").appendChild(glyphPad);
glyphPad.addEventListener("glyphchange", updateImage, false);
ID("glyph-options").addEventListener("change", function(e){
updateImage();
}, false);
ID("reset-button").addEventListener("click", function(e){
ID("glyph-options").reset();
updateImage();
}, false);
function updateImage(){
var glyph = glyphPad.getGlyph();
ID("glyph-word").value = gm9igt.glyphDic.getWordsFromGlyph(glyph);
// Create Glyph Element(canvas or svg)
var options = {
svg: ID("glyph-svg").checked,
size: parseInt(ID("glyph-size").value),
};
var glyphStyle = {
color: ID("glyph-color").value,
glyph:{
visible: ID("glyph-visible").checked,
lineWidth: parseInt(ID("glyph-line-width").value),
radiusRate: parseFloat(ID("glyph-diameter").value)/2
},
grid:{
color: ID("grid-color").value,
visible: ID("grid-visible").checked,
lineWidth: parseInt(ID("grid-line-width").value),
fill: ID("grid-fill-enabled").checked ? ID("grid-fill-color").value : "none",
nodeRadius: parseInt(ID("grid-node-radius").value)
},
hexagon:{
color: ID("hexagon-color").value,
visible: ID("hexagon-visible").checked,
lineWidth: parseInt(ID("hexagon-line-width").value),
fill: ID("hexagon-fill-enabled").checked ? ID("hexagon-fill-color").value : "none",
radiusRate: parseFloat(ID("hexagon-diameter").value)/2
},
};
var glyphElement = options.svg ?
gm9igt.createGlyphSVG(glyph, options.size, glyphStyle) :
gm9igt.createGlyphImage(glyph, options.size, glyphStyle);
// Show Image
var divGlyphElement = ID("glyph-element");
while(divGlyphElement.firstChild){
divGlyphElement.removeChild(divGlyphElement.firstChild);
}
divGlyphElement.appendChild(glyphElement);
// Show Image As Text
var glyphText = options.svg ?
divGlyphElement.innerHTML :
glyphElement.toDataURL();
ID("glyph-text").value = glyphText;
}
updateImage();
function setGlyphFromWord(word){
glyphPad.setGlyph((gm9igt.glyphDic.getGlyphsFromWord(word) || [null])[0]);
}
</script>
</body>
</html>